Quote: when using binding checkbox checked (slow and sometimes error at run time) while using "checkstate" works correctly. Is there way to bind checkbox with checked and unchecked only with null represented as unchecked
Sub bindingTest(container As Control, sql As String, BindingSource1 As BindingSource, BindingNavigator1 As BindingNavigator) Dim field As String Dim str As String = "" da = New SqlDataAdapter(sql, CSql.sqlDatabaseConnString) ds = New DataSet() da.Fill(ds) BindingSource1.DataSource = ds.Tables(0) ' BindingSource1.DataSource = dt.TableName BindingNavigator1.BindingSource = BindingSource1 For Each oc As Control In container.Controls If (TypeOf (oc) Is CheckBox) Then Dim oType As CheckBox oType = CType(oc, CheckBox) field = oType.Tag.ToString oc.DataBindings.Clear() If varcheckState = True Then '' working fine ' oType.DataBindings.Add(New Windows.Forms.Binding("checkstate", BindingSource1, field, True)) oType.DataBindings.Add("checkstate", BindingSource1, field, True) Else ''' slow and sometimes not working ' oType.DataBindings.Add(New Windows.Forms.Binding("Checked", BindingSource1, field, False)) oType.DataBindings.Add("Checked", BindingSource1, field, True) End If End If Next End Sub
oType.DataBindings.Add("Checked", BindingSource1, field, True)
true
false
null
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)