none
DataGridView : ScrollBars not showing RRS feed

  • General discussion

  • Hi all.

      I have a WinForms application. It is c#, .NET 2.0. On a form, I have 3 DataGridView controls. They all have their ScrollBars property set to Both. The scroll bars for the first two grids work ok, the third grid never shows them. There is absolutely no difference in the definition of the grids. The only difference is that the 3rd gird is wider. So far, I've tried to:

    - set the AutoSizeMode property of the columns to different values, did not work.

    - set the AutoSizeColumnsMode of the grid, it did not work.

    - changed the size of the grid, it did not work(originally it was wider than the form. Making it smaller did not work).

     

    Does anybody know what I can do to get the 3rd grid to show the scrollbars ?

    Thanks in advance for your help,

     

    EM

     

    Sunday, November 4, 2007 9:14 PM

All replies

  • Odd problem. Try: delete the third one, and drag a new one onto the form, bind it.

    Thursday, November 8, 2007 8:35 AM
  • Thanks for that!

    Actually, I did not replace the grid, just cut it and pasted it again on to the same container, and the scrollbars appeared(the horizontal one even at design time!).

    It would be great if you could tell if  there is any setting in the Form.designer.cs that we can override instead of having to cut and paste. This is so that we do not forget to re-attach all the event handlers.

    By the way, the problem is solved, but I cannot find a way to "mark as answer".

    Thanks very much for your help.

    EM

     

    Monday, November 12, 2007 9:13 PM
  • i have the same problem.
    finally, i found that this is due to i set all the columns property Frozen to True. i guess this property is designed for the Freeze Cell in Excel.
    hope this help.

    Wednesday, November 28, 2007 9:12 AM
  • Thanks for that. As I mentioned in my previous post, I fixed the problem by cuting and then pasting the grid back again into the form. I just cannot seem to find the "mark as answered"  option anywhere when posting.

    Of course, it would be better if someone knew which setting is cleared by cuting/pasting, so that rather than having to do that we just changed the setting of the DataGridView.

    Thanks again,

    E

    Wednesday, November 28, 2007 6:54 PM
  •  

    I found out that the fix for this problem is to reduce the size of the grid view to be smaller than its parent window and this will make the scroll bars to show.
    Thursday, January 3, 2008 3:13 PM
  • At design

    set datagridview size less than parent container (window, panel...)

    set scroll to BOTH

    finaly

    set Dock to FILL

     

    Thank

    Monday, August 23, 2010 5:50 AM
  • I solved the problem by:

    1. Adding a Panel to the TabControl.
    2. Positioning and sizing the Panel equal to the size I wanted the Data Grid.
    3. Putting the Data Grid in the Panel.
      - The Data Grid has the Scrollbars property set to Both.
    4. Setting the Dock property of the Data Grid to Fill (select the middle area on the drop down for Dock).
    5. Voila... after DataBind the scrollbar was now behaving as expected.

    I hope this helps someone else.

    Bror

    Wednesday, March 9, 2011 5:56 PM
  • I came across this post while trying to solve the same problem.  I had a datagridview with databinding and when it was filled, it resized right off the form, with no scroll bars. I realized I'd set the grid itself to autoresize.  As soon as I set autoresize (of the grid, not the col or row) back to false, scrollbars appear again.

    Seems kind of obvious now... if the grid resizes to fit the data, there is no need for scrollbars :)

    dataGridView1.AutoSize = false; // or set in control properties

    Monday, October 15, 2012 4:18 AM
  • This solved it for me. Thanks.
    Thursday, January 23, 2014 3:13 PM
  • Helped me, I thought I was losing my mind.
    Wednesday, December 10, 2014 6:47 AM
  • Thank you so much .....

    Wednesday, March 25, 2015 9:09 AM
  • HI , I do not see this property in my design view of Data grid and my data are dynamically bound , means number of columns can change depending on query. How can I make sure my columns are  Frozen? I am using Winform /VS2017

    JRS

    Tuesday, February 19, 2019 11:52 PM
  • Yes same worked for me. Cut and paste DataGridView on my UserControl.

    JRS

    Tuesday, February 19, 2019 11:53 PM
  • Intellisense and the reference document say the AutoSize property does not apply to the DataGridView. That's presumably why it doesn't appear in the property grid. 

    But I also found that setting it made the scrollbars appear as above.

    Sunday, December 1, 2019 2:07 PM