本文介绍了以编程方式对未绑定的数据网格视图进行排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要以编程方式对 datagridview 进行排序.我用谷歌搜索了很多,但没有任何效果.
I need to sort the datagridview programmatically. I googled a lot but nothing worked for me.
Datagridview 未绑定到任何数据源.正在手动添加数据.我的要求是在按下排序"按钮时对其进行排序.
Datagridview is not bound to any datasource. Data is being added manually.My requirement is to sort it as when a 'Sort' button is pressed.
谁能建议我在 vb.net 中编写代码?
Can anyone suggest me code in vb.net?
推荐答案
试试这个
DataGridView1.Columns(0)
-> 给出要排序的列System.ComponentModel.ListSortDirection.Ascending
-> 给出上升或下降的方向
DataGridView1.Columns(0)
-> Give which column you want to sortSystem.ComponentModel.ListSortDirection.Ascending
-> Give direction of ascending or decending
Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
DataGridView1.Sort(DataGridView1.Columns(0),
System.ComponentModel.ListSortDirection.Ascending)
End Sub
这篇关于以编程方式对未绑定的数据网格视图进行排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!