Checkbox and Databinding at Design time

M

M

I binding controls to a dataset at design time.
I find the checkboxs will cause the program crash when one of these
databinding fields is dbnull.
The only way for me is not set databindings for the checkboxs and adding
code after fill the dataset and before update the dataset.
I bind them to the checked property
Is there some easy way to set databinding for checkbox?

Thanks
 
O

One Handed Man \( OHM - Terry Burns \)

MyCheckBox.DataBindings.Add( . . . . .

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .
If U Need My Email ,Ask Me

Time flies when you don't know what you're doing
 
M

M

I do not see any differnce from set data binding at design time.
It still will cause the prgram crash if the field is dbnull.
 
M

M

Right Now I am using
'Fill Dataset
If MyDs.tables(0).Columns.Item(1) Is System.DBNull.Value Then
MyDs.tables(0).Columns.Item.Rows(0).Item(1) = False
End If

and

'Update dataset
MyDs.tables(0)..Rows(0).Item("GuidelinesMaxReg") = Me.Chkbox.Checked

It works

But I think Textbox or c1NumericEdit accept binding to field which value may
be dbNull.value.
If there are some properties can be set and make the checkbox also can do
that way and save me some coding.
 
C

Cor Ligthert

M,

I did not test it, (copied from a program and changed somewhat) you can try
it in this way.

Maybe you can try it for yourself?

Cor
\\\
Dim Mybinding as New Binding("Checked", dv, "MyCheckItem")
AddHandler Mybinding.Format, AddressOf DBtoCheckbox
////
\\\
Private Sub DBtoCheckbox(ByVal sender As Object, _
ByVal cevent As ConvertEventArgs)
If cevent.Value Is DBNull.Value Then
cevent.Value = False
End If
End Sub
///
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top