我的DataGridView效果不佳。这是我的代码,我只想显示4列,第一列是复选框列。
Dim dt_zone As DataTable
Dim iCounter As Integer
dt_zone = obj_aims_zone.get_row_for_display("", area_id)
dvg_selected_group_list.DataSource = Nothing
If dt_zone IsNot Nothing Then
If dt_zone.Rows.Count > 0 Then
dvg_selected_group_list.DataSource = dt_zone
For Each row As DataGridViewRow In dvg_selected_group_list.Rows
If row.Cells(3).Value.ToString.Equals(group_id) Then
row.Cells(check.Index).Value = True
End If
row.Cells(1).ReadOnly = True
row.Cells(2).ReadOnly = True
row.Cells(3).ReadOnly = True
row.Cells(4).ReadOnly = True
Next
For iCounter = 1 To 7
dvg_selected_group_list.Columns.RemoveAt(5)
Next
End If
End If
答案 0 :(得分:0)
我知道这是从前一段时间开始的,但删除你不想要的列似乎更容易:
dataGridView.Columns.Remove("column name")