0

I have a VB.NET form and I have added a checkbox. I am using databindings for this checkbox as per below:

txtID.DataBindings.Clear()
txtID.DataBindings.Add("Text", ds.Tables(0), "ID")

Dim MyID As New Binding("Checked", ds.Tables(0), "UserID")
AddHandler MyID.Format, AddressOf chkFormatter
AddHandler MyID.Parse, AddressOf chkParser
chkID.DataBindings.Add(MyID)

If I check the box it checks fine, but once I click onto another field, the checkbox loses its check.

Can anyone help me understand why please?

I have other checkboxes on the form that are using databindings in the same way and they are working fine.

Thank you,

1 Answer 1

0

understand you bind MyId to "UserId", so is "UserId" a boolean field?

if yes, does any piece of the code update this field from other means?

2
  • Yes it is, and no it is not updated elsewhere. I've actually searched for all instances of the checkbox and it's not found outside of 1 entry behind the save button where I pass the value in to the update function. Jul 31, 2013 at 8:45
  • try to use New Binding("Checked", ds.Tables(0), "UserID", True, DataSourceUpdateMode.OnPropertyChanged), if still no luck, you may handle chkbox.LostFocus event to monitor the databinding state: the underlying object/datarow's UserId value
    – Rex
    Jul 31, 2013 at 9:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.