Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27192

Converting a DataGridView Column to a DataGridViewCheckBoxCell?

$
0
0
There may be more than 1 way to do what I am trying. I have a DGV that I manually bind to a dataset. This dataset contains 5 columns that will be used as checkbox columns in my grid. My problem is, I'm not sure how to convert them to a DataGridViewCheckBoxCell once the Grid's DataSource has been assigned the DataSet. This is what I have so far and ends up looking like the screenshot.

Code:

    Private Sub SetupUPGrid()
        Dim dt As New DataTable

        dt = BL.GetUserPermissions
        dgvUP.DataSource = dt

        With dgvUP
            .AutoGenerateColumns = False

            Dim cboCol1 As New DataGridViewCheckBoxColumn
            cboCol1.HeaderText = "All"
            cboCol1.Width = "75"
            .Columns.Add(cboCol1)
            Dim cboCol2 As New DataGridViewCheckBoxColumn
            cboCol2.HeaderText = "Add"
            cboCol2.Width = "75"
            .Columns.Add(cboCol2)
            Dim cboCol3 As New DataGridViewCheckBoxColumn
            cboCol3.HeaderText = "Change"
            cboCol3.Width = "75"
            .Columns.Add(cboCol3)
            Dim cboCol4 As New DataGridViewCheckBoxColumn
            cboCol4.HeaderText = "Delete"
            cboCol4.Width = "75"
            .Columns.Add(cboCol4)
            Dim cboCol5 As New DataGridViewCheckBoxColumn
            cboCol5.HeaderText = "View"
            cboCol5.Width = "75"
            .Columns.Add(cboCol5)
        End With
    End Sub

Attached Images
 

Viewing all articles
Browse latest Browse all 27192

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>