Wednesday, September 16, 2009

Horizontal scroll bar NOT appears in DataGridView control in Window application

Horizontal scroll bar NOT appears in DataGridView control in Window application


I am using Visual Studio.Net 2005 and working with VB.NET Window application, in one of the window form when I tried to set DataGridView ScrollBars property as ScrollBars.Both then only Vertical scroll bar display in the grid But Horizontal scroll bar not appears in the grid.


After doing some analysis I found if DataGridView AutoSizeColumnsMode property is set as DataGridViewAutoSizeColumnsMode.Fill then you will not able to see the horizoltal scroll bar in the grid. SO to see both the scroll bar in the grid make sure you set


DataGridView1.AutoSizeColumnsMode = NONE (Default) And

DataGridView1.ScrollBars = ScrollBars.Both (Default)

3 comments:

Anonymous said...

nice post. thanks.

Anonymous said...

I also found that if you have a a number of forzen columns (I suspect more columns frozen than are dsiplayed in the grid width by default) you will also lose the horizontal scroll bars.

Anonymous said...

Build horizontal scrollbar in DataGridView in C# Windows Forms