ScrollBar in DataGridView

后端 未结 3 1570
南旧
南旧 2020-12-20 06:00

I have a winform in vs2008 that contains a DataGridView. The datagrid contains a list with several columns. These are fixed width, exept one that I have set up to take whate

相关标签:
3条回答
  • 2020-12-20 06:25

    In my case, (re)sorting the grid helped. Try sth like this:

     if (gridName.SortedColumn == null)
       gridName.Sort(gridNameColumns[columnName],ListSortDirection.Ascending);
     else
     {
        ListSortDirection dir;
        if (gridName.SortOrder == SortOrder.Descending) 
           dir = ListSortDirection.Descending;
        else dir = ListSortDirection.Ascending;
    
        gridName.Sort(gridName.SortedColumn, dir);
     }
    
    0 讨论(0)
  • 2020-12-20 06:30

    Try subclassing the DataGridView and handling the VerticalScrollBar's VisibleChanged event. You should be able to set the Visible property to True in there, overriding the default behaviour.

    Something like this, I think...

    public class SubclassedDataGridView : DataGridView
        {
            public SubclassedDataGridView (): base()
            {
                VerticalScrollBar.VisibleChanged += new EventHandler(VerticalScrollBar_VisibleChanged);
            }
    
            void VerticalScrollBar_VisibleChanged(object sender, EventArgs e)
            {
                VerticalScrollBar.Visible = true;
            }
         }
    
    0 讨论(0)
  • 2020-12-20 06:33

    One of the possibility is to trigger the event of when the scrollbar is disapearing so you can prevent the event and stop it.

    0 讨论(0)
提交回复
热议问题