How to detect the vertical scrollbar in a DataGridView control

后端 未结 7 757
半阙折子戏
半阙折子戏 2021-01-05 05:19

Using winforms in vs2008. I have a DataGridView and I would like to detect when the vertical scroll bar is visible. What event should I register for?

I am adding the

7条回答
  •  孤独总比滥情好
    2021-01-05 05:57

    If your dgv is inside a panel then you can compare panel and dgv height properties. If dgv's is bigger than panel's then there must be a scrollbar, right?

    Like :

    int panel_height = pnl.Height;
    int dgv_height = (dgv.RowCount + 1) * 24; // You can play around with this 24 according to your cell styles
    if (dgv_height > panel_height) MessageBox.Show("Voila!");
    

提交回复
热议问题