Quantcast
Channel: Windows Forms Data Controls and Databinding forum
Viewing all articles
Browse latest Browse all 2535

Checkbox databinding and Y/N values

$
0
0
I have searched around and not found a solution for this, so I am creating a new thread...

I have a number of checkboxes on a form that I would like to databind to columns in my datatable.  Each of these columns is a single character string with a value of "Y" or "N" (never null).

I have successfully bound textboxes and comboBoxes with statements like:

 this.txtMyTextField.DataBindings.Add("Text", MyDataTable, "MY_TEXT_COLUMN");
 this.cmbMyComboBox.DataBindings.Add("SelectedValue", MyDataTable, "MY_CMB_COLUMN");

However, I cannot come up with a solution for checkboxes.  I have tried:
 this.chkMyCheckBox.DataBindings.Add("Checked", MyDataTable, "MY_Y_N_COLUMN");

but, it seems that the checkbox databinding is making an assumption that the column passed in will always be a boolean.

Is this correct?

Can anyone think of a workaround for this?  I will need to do this in a whole bunch of places, so anything that makes it easier is greatly appreciated.

Thanks,

mp

Viewing all articles
Browse latest Browse all 2535

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>