2011-05-12 132 views
0

我的DataGridView不能正常工作。这是我的代码,我只想显示4列,第一列是复选框列。复选框选择和删除datagridview中的列

 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 
+1

究竟什么是您所遇到的问题? – 2011-05-12 15:05:39

+0

你能告诉一些关于dt_zone数据源的东西吗?你所显示的代码看起来应该是你想要的,尽管这不是我将要写的。 – 2011-05-12 15:20:47

+0

我的问题是复选框没有检查,我删除的列是不删除,在datagridview,显示在dt_zone整个数据,我想显示只有4列与复选框列各 – nyizawhan 2011-05-13 01:41:11

回答

0

我知道这是来自前一段时间,但它似乎更容易删除你不想要的列:

dataGridView.Columns.Remove("column name")