Public Sub BindDatagridview(ByVal dt As DataTable, ByVal dg As DataGridView)
Dim dv As DataView
With dt
'Outstanding check List_MouseDown
Dim SQL As String = String.Empty
'Initialize the image column.
If dg.Name <> "DgHelpUsers" Then
.Columns.Add("Sel", GetType(Object))
.Columns("Sel").SetOrdinal(0)
End If
If dt.Rows.Count <> 0 Then
dg.DataSource = dt
dg.Rows(0).Selected = False
dg.ClearSelection()
For inti = 0 To dg.DataSource.columns.count - 1
dg.Columns(inti).SortMode = DataGridViewColumnSortMode.Programmatic
Next
If dg.Name <> "DgHelpUsers" Then
With dg.Columns("Sel")
.ToolTipText = "Selection"
.HeaderText = ""
.DefaultCellStyle.ForeColor = Color.Transparent
.Width = 15
End With
End If
Else
'The datatable is empty so load only the columns
dv = New DataView(dt)
'add code for sorting as original defaultview
dg.DataSource = dv
End If
End With
End Sub
I think you will have to loop through all the rows in the datagridview and explicitly set the value of the cheeckbox to whatever you want.