troubleshooting Question

Setting a CheckBox Column to True in a DataGridView?

Avatar of BlakeMcKenna
BlakeMcKennaFlag for United States of America asked on
Visual Basic.NET
21 Comments1 Solution519 ViewsLast Modified:
I have a DataGridView that has 4 columns. The first column is defined as a CheckBoxCell. This DGV and it's columns are created in design mode. My problem is that when I add a row of data to the Grid, the 1st column, which is the checkbox doesn't show as a CheckBox Column rather just as a TextBoxCell. Below is my code:

    Private Sub AddShuntValueToGrid()
        Try
            Dim rowCnt As Integer = 0

            dgvShunts.Rows.Add()
            rowCnt = dgvShunts.RowCount

            dgvShunts.Rows(rowCnt - 1).Cells(0).Value = True
            dgvShunts.Rows(rowCnt - 1).Cells(1).Value = cmbShuntValues.Text & "K"
            dgvShunts.Rows(rowCnt - 1).Cells(2).Value = cmbShuntConnections.Text
            dgvShunts.Rows(rowCnt - 1).Cells(3).Value = String.Empty

            dgvShunts.Rows(rowCnt - 1).Cells(3).ReadOnly = False
            dgvShunts.CurrentCell = dgvShunts(3, rowCnt - 1)

        Catch ex As Exception
            EH.strRetVal = "frmCalibration_SizeChanged() - " & ex.Message & "...Contact Engineering!" & "~E"
        End Try

        EH.ProcessMessages(Me, sbr, EH.strRetVal)
    End Sub
Screenshot.jpg
ASKER CERTIFIED SOLUTION
BlakeMcKenna

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 21 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 21 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros