in vb.net visual studio 2013 windows forms
I notice when using in 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 without null without problems
Sample code include
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)
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))
Else
''' slow and sometimes not working
oType.DataBindings.Add(New Windows.Forms.Binding("Checked", BindingSource1, field, False))
End If
End If
Next
End Sub
Aucun commentaire:
Enregistrer un commentaire