Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# DataGridView- How enable vertical scrollbar

The DataGridView (Form) holds enough rows that the vertical Scrollbar is shown. But its not enabled. The Silder for Movement is missing and the Button Up and Button Down are greyed out.

=> there is a vertical scrollbar but not enabled.

I tried:

  1. After filling the DataGridView the control is updated.
  2. Resizing the entire Panel.
  3. The Frozen attribute is false.
  4. I a click in a cell i can use the up and down keys to scroll, but the scrollbar will not be enabled.

If I resize the Control while running (DataGridView is on a Splitpanel) the Scrollbar can be used e.g its now enabled.

like image 752
Thomas Avatar asked May 31 '12 11:05

Thomas


3 Answers

Try this:

1. One of your columns has probably frozen property set as True.

which should be False for all columns.

2. Set the AutoSizeMode of the problematic column to AllCells

3. mygrid.DockStyle = DockStyle.Fill

like image 105
lolo Avatar answered Sep 20 '22 04:09

lolo


Set ScrollBar property of datagridview is Both.

like image 40
Asif Avatar answered Sep 20 '22 04:09

Asif


The same problem plus some workarounds can be found here: DataGridView vertical scrollbar not updating properly (Forms bug?)
It definitely seems to be a winforms bug that appears, e.g. when a DGV is placed inside a tab of a tabcontrol.

like image 40
Tobias Knauss Avatar answered Sep 18 '22 04:09

Tobias Knauss