none
custom scrollbar for datagridview

    Question

  • Is there a way to disable vertical scrollbar for datagridview and have a vscrollbarcontrol scroll the datagridview? if yes, any suggestions, examples?

    I want to use a custom scrollbar that has gradient paintings for the datagridview.

    Friday, November 11, 2005 7:28 AM

Answers

  • The way I posted is a safe way. Depending upon how much code you want to write it would probably be the preferred way. An alternate way would be to keep the DGV's Vertical scroll bar visible, but put your custom scrollbar over the top of it. This would enable you to query the DGV's vertical scroll (via the protected VerticalScrollBar property) to set the appropriate Maximum and Minimum values. You could also listen to the Location and Size Changed events to keep your custom scroll bar in sync.

    -mark
    DataGridView Program Manager
    Microsoft
    This post is provided "as-is"

    Monday, November 14, 2005 10:32 PM

All replies

  • You can set the ScrollBars property to be None to remove the vertical scrollbar. After you add your own vscroll bar control, you'll need to hook the Scroll event and set the FirstDisplayedScrollingRowIndex property based upon the position of your scrollbar. You'll also need to set the appropriate Maximum value.

    -mark
    DataGridView Program Manager
    Microsoft
    This post is provided "as-is".
    Friday, November 11, 2005 9:32 PM
  • Thanks Mark, just to confirm, is this a safe and preferred way of doing?
    Saturday, November 12, 2005 1:57 AM
  • The way I posted is a safe way. Depending upon how much code you want to write it would probably be the preferred way. An alternate way would be to keep the DGV's Vertical scroll bar visible, but put your custom scrollbar over the top of it. This would enable you to query the DGV's vertical scroll (via the protected VerticalScrollBar property) to set the appropriate Maximum and Minimum values. You could also listen to the Location and Size Changed events to keep your custom scroll bar in sync.

    -mark
    DataGridView Program Manager
    Microsoft
    This post is provided "as-is"

    Monday, November 14, 2005 10:32 PM
  • Hello everybody,

    so I want to put my own scrollbars right and bottom of the DataGridView, and wants to synchronize them with DataGridView. Everything works fine, but one thing is still missing:

    Standard behaviour of a DataGridView is to show scrollbars only if necessary. Are there possibilities to check whether GridView needs to display scrollbars? Or have I to calculate current container width and check it with Grid-width?

    Thanks for any help,
    Norman-Timo
    Friday, September 01, 2006 8:56 AM
  • There aren't any methods that will tell you "yes you need a scroll bar" but you can use some of the Columns collection methods such as GetColumnsWidth to help you determine this.

    -mark
    Program Manager
    Microsoft
    This post is provided "as-is"

    Friday, September 01, 2006 5:59 PM
  • Hello Mr. Rideout,

    thanks. I thougth I have to calculate Width and Height and compare it with Drawing rectangle, but you confirmed my thoughts.

    Thx and bye,
    Norman-Timo
    Tuesday, September 05, 2006 3:32 PM
  • Turns out there is an easier way to deal with these things: through the AutoSizeColumnsMode of the DataGridView.  Set that to Fill, then manipulate the individual columns' AutoSizeMode to set which of them will shrink/grow depending on the presence of the scroll bar, and which ones will stay the same width.  Works well.
    Monday, May 07, 2007 9:47 PM
  • Hi,

     

        I have the same requirement. I need to scroll data grid view through my custom scroll bar. I am able to find out the maximum and large change of scroll but unable to scroll the datagrid view through my scroll bar. Can anybody help me in this?

     

     

    Thanks

    Sajal Mahajan

    Thursday, March 27, 2008 4:26 AM
  • Norman, you said that you have managed to put your own scrollbars right and bottom for the DataGridView, How do you calculate and set the minumum, Maximum, LargeChange and smallchange values ?

    Kamath

    Wednesday, August 01, 2012 10:10 AM