-
DatagridBoolColumn
Is there an equivalent to the C# DatagridBoolColumn for VB?
Is there a way to programmaticaly create a bool checkbox column and to set the checkboxes to true or false based on the dataset values.
I have a templatecolumn with checkboxes but how do I bind data to that column?
-
This will add a new bool checkbox column to your data grid then check the value of the "password" column and check the checkbox if the rows password="145":
Code:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Add a new check box column to your datagrid"
ds1.Tables(0).Columns.Add(New DataColumn("calculatedField", GetType(Boolean)))
'Set the default value to false "Unchecked"
ds1.Tables(0).Columns("calculatedField").DefaultValue = False
'Fill your dataset
da1.Fill(ds1)
'Check your new column if the rows "password" column = 145
Dim i As Integer
With ds1.Tables(0)
For i = 0 To .Rows.Count - 1
If .Rows(i)("Password") = "145" Then
.Rows(i)("calculatedField") = True
End If
Next
End With
End Sub