By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,815 Members | 1,143 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,815 IT Pros & Developers. It's quick & easy.

Checkbox and Databinding at Design time

P: n/a
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
Nov 21 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
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" <mx****@hotvoice.com> wrote in message
news:O2**************@tk2msftngp13.phx.gbl...
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

Nov 21 '05 #2

P: n/a
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.

"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in message
news:OX*************@tk2msftngp13.phx.gbl...
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" <mx****@hotvoice.com> wrote in message
news:O2**************@tk2msftngp13.phx.gbl...
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


Nov 21 '05 #3

P: n/a
M,

Because your database item is not the same type as your databinding would
expect. therefore I think you can surely not do it at design time.

You can try to use the binding events
http://msdn.microsoft.com/library/de...ventstopic.asp

click on the member there is more information.

I hope this helps?

Cor
Nov 21 '05 #4

P: n/a
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.
Nov 21 '05 #5

P: n/a
M,

Can you assign a default value to that column in your database?

"M" <mx****@hotvoice.com> wrote in message news:et****************@TK2MSFTNGP09.phx.gbl...
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.

Nov 21 '05 #6

P: n/a
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
///
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.

Nov 21 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.