Sql server 获取DataGridView标头的集合
Sql server 获取DataGridView标头的集合,sql-server,vb.net,Sql Server,Vb.net,我有一个DataGridView和一个组合框(用于排序),我想在运行应用程序时获得DataGridView头的集合,并使其成为我的组合框的数据源我通过深入研究得到了它 Dim ch As New List(Of String) For Each header As DataGridViewColumn In DataGridView1.Columns ch.Add(header.HeaderText) Next cbSort.DataSource = ch 我创建一个变量作为字符串数
我有一个DataGridView和一个组合框(用于排序),我想在运行应用程序时获得DataGridView头的集合,并使其成为我的组合框的数据源我通过深入研究得到了它
Dim ch As New List(Of String)
For Each header As DataGridViewColumn In DataGridView1.Columns
ch.Add(header.HeaderText)
Next
cbSort.DataSource = ch
我创建一个变量作为字符串数组,然后循环遍历我的DatagridView
的列,获取每个列标题并将其分配给我的数组变量。
然后我将其设置为我的组合框的数据源
我看到的一些参考资料并有了一个想法: