How to Bind a checkbox to a binding source object

Hi,
I am using VB.net 2008 and i am having trouble binding to a checkbox on my form.
this is my code
           'chkLevyCharge.Checked = False
            'chkLevyCharge.DataBindings.Clear()
            'chkLevyCharge.DataBindings.Add("Checked", bs, "LevyCharge")
it binds to it and when i scroll through the bs object it works, however the problem is when i try and add a new record to the bs (dataset)
bs.addNew() it does not clear the rest of my text boxes which i have bound to the bs, when i comment out the section of code binding to the checkbox then the bs.addnew() method works

thanks
LVL 4
CraigLazarAsked:
Who is Participating?
 
DabasConnect With a Mentor Commented:
The code above is in the designer.vb or in your own code?

Dabas
0
 
CodeCruiserConnect With a Mentor Commented:
move the code of binding to the checkbox to the bottom and keep other bindings on the top.
0
 
CraigLazarAuthor Commented:
hi the code is not in the vb designer.

to code cruiser
i have bound text fields as well and i am using the same method
            txtAmount.Text = ""
            txtAmount.DataBindings.Clear()
            txtAmount.DataBindings.Add("Text", bs, "Amount")

my code to bind to the checkbox is at the bottom
0
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

 
DabasCommented:
Have you tried without the .Clear() line?
0
 
CraigLazarAuthor Commented:
to Dabas:
yes i tried that and still same problem
0
 
CodeCruiserCommented:
Set a default value for the checkbox column in the dataset. I think the problem is that the field to which the checkbox is bound contains DBNull when a new record is inserted which may be causing problems.
0
 
CraigLazarAuthor Commented:
Hi,
i still battled to get it working, so i landed up using a hidden text box to store the value then i got it working
thanks for the help anyway
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.