I have the following datagrid but the checkboxes are not behaving normally. I expect each checkbox to accept 1 click to change state and another click to change it back but this is not happening.

When I check on one of the boxes, it will select the entire row, and if I check it again, it will then change the state. Then the next click will select the row again, and the following click will change the state back.

How can I stop the grid from selecting the entire row, and just change the state of the checkbox for each click?

VB Code:
  1. Public dtSession As New DataTable("SessionTable")
  2.     Public dsSession As DataSet = New DataSet("SessionData")
  3.     Public sSessionId As String = "Session ID"
  4.     Public sSessionDesc As String = "Session Descripton"
  5.     Public sSessionCB1 As String = "CB1"
  6.     Public sSessionCB2 As String = "CB2"
  7.     Public sSessionCB3 As String = "CB3"
  8.     Public sSessionCB4 As String = "CB4"
  9.  
  10.  
  11.     Public Sub sessionDataGrid_Load()
  12.  
  13.         Dim myRow As DataRow
  14.         Dim x As Integer
  15.         Dim dgts As New DataGridTableStyle
  16.         Dim dgcs1 As New DataGridTextBoxColumn
  17.         Dim dgcs2 As New DataGridTextBoxColumn
  18.         Dim dgcs3 As New DataGridBoolColumn
  19.         Dim dgcs4 As New DataGridBoolColumn
  20.         Dim dgcs5 As New DataGridBoolColumn
  21.         Dim dgcs6 As New DataGridBoolColumn
  22.         Dim cb1, cb2, cb3, cb4 As DataColumn
  23.  
  24.                Try
  25.             sessionDataGrid.CaptionText = "Sessions Currently in Data Base"
  26.             dtSession.Clear()
  27.             dtSession.Columns.Add(New DataColumn(sSessionId, GetType(String)))
  28.             dtSession.Columns.Add(New DataColumn(sSessionDesc, GetType(String)))
  29.  
  30.             cb1 = New DataColumn(sSessionCB1, GetType(Boolean))
  31.             cb1.ReadOnly = False
  32.             cb1.DefaultValue = False
  33.             dtSession.Columns.Add(cb1)
  34.  
  35.             cb2 = New DataColumn(sSessionCB2, GetType(Boolean))
  36.             cb2.ReadOnly = False
  37.             cb2.DefaultValue = False
  38.             dtSession.Columns.Add(cb2)
  39.  
  40.             cb3 = New DataColumn(sSessionCB3, GetType(Boolean))
  41.             cb3.ReadOnly = False
  42.             cb3.DefaultValue = False
  43.             dtSession.Columns.Add(cb3)
  44.  
  45.             cb4 = New DataColumn(sSessionCB4, GetType(Boolean))
  46.             cb4.ReadOnly = False
  47.             cb4.DefaultValue = False
  48.             dtSession.Columns.Add(cb4)
  49.  
  50.             dgcs1.MappingName = sSessionId
  51.             dgcs1.ReadOnly = True
  52.             dgcs1.HeaderText = sSessionId
  53.             dgts.GridColumnStyles.Add(dgcs1)
  54.  
  55.             dgcs2.MappingName = sSessionDesc
  56.             dgcs2.ReadOnly = True
  57.             dgcs2.Width = sessionDataGrid.Size.Width / 3
  58.             dgcs2.HeaderText = sSessionDesc
  59.             dgts.GridColumnStyles.Add(dgcs2)
  60.  
  61.             dgcs3.MappingName = sSessionCB1
  62.             dgcs3.ReadOnly = False
  63.             dgcs3.AllowNull = False 'Makes the checkbox 2 state
  64.             dgcs3.HeaderText = sSessionCB2
  65.             dgts.GridColumnStyles.Add(dgcs3)
  66.  
  67.             dgcs4.MappingName = sSessionCB2
  68.             dgcs4.ReadOnly = False
  69.             dgcs4.AllowNull = False 'Makes the checkbox 2 state
  70.             dgcs4.HeaderText = sSessionCB2
  71.             dgts.GridColumnStyles.Add(dgcs4)
  72.  
  73.             dgcs5.MappingName = sSessionCB3
  74.             dgcs5.ReadOnly = False
  75.             dgcs5.AllowNull = False 'Makes the checkbox 2 state
  76.             dgcs5.HeaderText = sSessionCB3
  77.             dgts.GridColumnStyles.Add(dgcs5)
  78.  
  79.             dgcs6.MappingName = sSessionCB4
  80.             dgcs6.ReadOnly = False
  81.             dgcs6.AllowNull = False 'Makes the checkbox 2 state
  82.             dgcs6.HeaderText = sSessionCB4
  83.             dgts.GridColumnStyles.Add(dgcs6)
  84.  
  85.             dgts.MappingName = "SessionTable"
  86.             sessionDataGrid.TableStyles.Add(dgts)
  87.  
  88.             For x = 0 To gSessions.Length - 2
  89.                 myRow = dtSession.NewRow()
  90.                 myRow(sSessionId) = Hex(gSessions(x).Id)
  91.                 myRow(sSessionDesc) = gSessions(x).Desc
  92.                 myRow(sSessionCB1) = True 'TODO:Get actual value later
  93.                 myRow(sSessionCB2) = True 'TODO:Get actual value later
  94.                 myRow(sSessionCB3) = True 'TODO:Get actual value later
  95.                 myRow(sSessionCB4) = False 'TODO:Get actual value later
  96.                 dtSession.Rows.Add(myRow)
  97.             Next
  98.  
  99.             dsSession.Tables.Add(dtSession)
  100.             sessionDataGrid.DataSource = dtSession
  101.  
  102.         Catch ex As Exception
  103.             MsgBox(ex.Message)
  104.         End Try
  105.  
  106.     End Sub