11

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.

Pablo Claus
  • 5,886
  • 3
  • 29
  • 38
Thomas
  • 1,545
  • 3
  • 14
  • 25
  • Did you try this? http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridview.horizontalscrollbar.aspx – Polynomial May 31 '12 at 11:55
  • 2
    if you are talking about rows, and button up and down, then I think you may be looking for the VerticalScrollbar – paul May 31 '12 at 11:56
  • refer http://social.msdn.microsoft.com/Forums/en-US/winformsdatacontrols/thread/9c9d2d67-c45f-4318-81ef-bf652358f582/ – Romil Kumar Jain May 31 '12 at 11:58
  • The problem is ->not<- the visibilty of the vertical scrollbar – Thomas May 31 '12 at 12:35
  • You tried to set the width property to a smaller value? – lolo May 31 '12 at 12:53
  • Yes i have changed the width. No there is a 20 pixel cap between the datagridview and the splitcontainer. But still not enabled – Thomas May 31 '12 at 13:41

6 Answers6

7

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

lolo
  • 17,392
  • 9
  • 25
  • 49
  • I double checked, and no - none of my columnes have frozen set as true. – Thomas May 31 '12 at 12:06
  • 2. | was: fill | is: AllCells | - and there it is , the sliders is enabled and can be used! How and Why? But thank you very much – Thomas May 31 '12 at 13:46
2
  1. You should dock fill your datagridview to panel
  2. If you have some frozen rows, make sure these rows are set after you finish bringing data to your gridview

If you set the frozen row before, the row when added will take the default style of the first row, and all your gridview rows will have the option row.frozen = true. That's why the vertical scroll won't appear.

Tim Malone
  • 3,364
  • 5
  • 37
  • 50
1

Set ScrollBar property of datagridview is Both.

Asif
  • 2,657
  • 19
  • 25
  • The DataGridView Class has no Propertie called AutoScroll (searched for this one too) See: http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridview.aspx – Thomas May 31 '12 at 12:16
  • earlier i was thinking that you are asking about Dot net bar datagridview control. – Asif May 31 '12 at 13:03
1

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.

Community
  • 1
  • 1
Tobias Knauss
  • 3,361
  • 1
  • 21
  • 45
1

I had a similar issue with the horizontal scroll bar. Doing PerformLayout on the grid didn't solve it. It turns out that the problem in my case was that the form was disabled. We have an infrastructure that disables the form on load, loads a bunch of stuff asynchronously and at the end enables the form. For some reason this was enough for the scroll bar to stay disabled when the form was enabled (and like in your scenario resizing the form while running enabled the scroll bar). So for me the solution was calling PerformLayout on the grid after enabling the form.

tzachs
  • 4,331
  • 1
  • 28
  • 28
0

I know this is really old, but this was frustrating me for weeks.

I have two DataGridViews on nested Panels. The DataGridViews are Dock->Fill, the Panels on which they reside are Dock->Fill within additional nested panels.

The vertical scroll bars were highly unreliable when the form was resized - often the scroll bar might be visible but disabled, even though I could manually scroll down the grid using the down arrow in the rows.

The final solution was using "Tzachs" suggestion - after any resize event, invoke the "PerformLayout()" method on the grids. This seems like a bug in the grid - failing to detect that the scroll bar is needed when the grid automatically resizes on a nested panel.

At least PerformLayout() solved my issues.

Kim Crosser
  • 413
  • 8
  • 13