开发者

checkbox selection and removing columns in datagridview

My DataGridView doesn't work well. This is my code, I only开发者_如何学C want to display 4 columns with the first column being a checkbox column.

        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


I know this was from awhile ago, but it would seem easier to delete the columns you don't want with:

dataGridView.Columns.Remove("column name")
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜