DataGrid Vertical Scrollbar Problem
Hi,
I have a .NET 1.1 WinForms app with a datagrid bound to a datatable. There are 53 records in the table, and the grid displays 7 or 8 at a time. When the form initializes, the data is sorted on the LineNumber column (as it should be).
The vertical scrollbar is visible but disabled. If I click on one of the column heads to sort the grid, the vertical scroll bar becomes enabled. If I then sort on LineNumber, as it was originally, the scrollbar remains enabled, as it should.
The question is, how do I enable the vertical scroll bar from the beginning? Am I forgetting something or is this a bug? Is there a workaround?
Thank.
[640 byte] By [
dhurwitz] at [2007-12-16]
The DataGrid doesn't support "paging", so I'm not sure how you are able to get the DataGrid to show only 7 or 8 lines at a time. Can you describe this in more detail?
thanks,
-mark
Program Manager
Microsoft
This post is provided "as-is"
I'm hoping you've already worked around this problem as it's been several months, however if you're still stuck. I encountered this problem myself and found a solution. It's worth noting that I did not encounter this problem with a stand alone datagrid, however once I placed the datagrid inside a tab control this problem did manifest. I can only assume this is a bug in the way the controls interact because I am unable to find the cause of this problem.
Right after binding the data to the datagrid re-enable the scrollbar. If you have a large datatable you'll find that both vertical and horizontal scrollbars are visible but disabled. Do this in the following manner:
datagrid.Controls[0].Enabled = true; // Index zero is the horizontal scrollbar
datagrid.Controls[1].Enabled = true; // Index one is the vertical scrollbar
...but make sure you do the above *after* applying any RowFilter criteria to the underlying DataView you are binding to, ...
...or the Scrollbars get disabled again! (at least mine do).
(I wonder, do you have to make sure that the Moon is in the seventh house too?)