Hi guys, I just want to know on how will I add a Checkbox in each row of my datagridview. First I used a datatable to get all the values from my database and then pass it all to the datagridview. What I want to happen is at the first column of my datagridview there is the checkbox. Here's my code..

dtfinal = New DataTable
        sda = New SqlDataAdapter("SELECT k.EMPL_ID,m.EMPL_LNAME + ', ' + EMPL_FNAME AS NAME,k.KPIPOSTCODE AS 'POSITION',k.YEARNUM,k.MONTHNUM,k.WKNUM,k.KRAWEEKGRADE,k.STATUS,k.ISOVERRIDE,k.PREV_KRAWEEKGRADE FROM KRAWEEK k JOIN KEMPMASTER m ON k.EMPL_ID = m.EMPL_ID WHERE k.STATUS='" & "FINAL" & "' ORDER BY YEARNUM,MONTHNUM,WKNUM", sqlcon)
        sda.Fill(dtfinal)
        If dtfinal.Rows.Count <> 0 Then
            dg4.DataSource = dtfinal
        Else
            dg4.DataSource = ""
        End If

A field in the SQL Select query with a datatype of Bit should give you a checkbox in the DataGridView.

i have one bit column in my table in SQL SERVER 2000 Database. the
DataGridView displays it as "True" or "False" instead of checkbox...

You can try to programmatically change the template to use for that column, after the databinding, while still having that Bit column.

If dtfinal.Rows.Count <> 0 Then
   dg4.DataSource = dtfinal
   Dim chkBox As New DataGridViewCheckBoxColumn(False)
   dg4.Columns(0).CellTemplate = chkBox.CellTemplate
Else
   dg4.DataSource = ""
End If
This article has been dead for over six months. Start a new discussion instead.