Checkbox and Databinding at Design time

  • Thread starter Thread starter M
  • Start date Start date
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
 
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
 
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.
 
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.
 
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
///
 
Back
Top