DataGridView: Scroll bar does not refreshed

Posted by David.Chu.ca on Stack Overflow See other posts from Stack Overflow or by David.Chu.ca
Published on 2010-05-12T22:29:58Z Indexed on 2010/05/12 22:34 UTC
Read the original article Hit count: 259

I am working (fixing bugs) on a project which was written in VS 2005. There is one DataGridView control on a form. When it is first time loaded, the control's data grid is populated with rows of data from a collection manually or in codes. Actually, there is method PopulateDataGrid() do the job.

There is also another control on the form. When control is changed, the data grid will be cleared first and then rows are repopulated again through PopulateDataGrid(). The problem is that when the grid is refreshed, the vertical scroll bar does not get reset correctly. I thought it should be. Since the scroll bar is not reset, when I tried to click on grid and move down, I got exception: the max value of scroll bar was exceeded.

All the settings for grid control are default values. For example, the ScrollBars is Both. The following is the only related place to set row auto size property:

poDataGridView.AutoSizeRowsMode =
            DataGridViewAutoSizeRowsMode.DisplayedCellsExceptHeaders;

I am not sure if there is any property I have to set in designer?

© Stack Overflow or respective owner

Related posts about visual-studio-2005

Related posts about datagridview