DataGridView Sort Programmatically

前端 未结 2 497
执念已碎
执念已碎 2021-01-25 02:38

I have created my custom DataGridViewNumericTextBoxColumn derived from DataGridViewTextBoxColumn class.

When I call

this.HeaderDataGridView.Sort = Sort.P         


        
2条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-25 03:24

    If you are using a binding source, you can simply set the .Sort property to the name of the column you want to sort on. For example:

    myBS = new BindingSource();
    myBS.DataSource = DataSet.MY_TABLE;
    myBS.Sort = "MY_COLUMN";
    myGrid.DataSource = myBS;
    

提交回复
热议问题