Combobox and Nullable Enum

B

Brian

Is there a way to bind a nullable Enum property to a combo box?

When choosing a value, and then leaving the combo box, the value reverts
back to the original value. It seems the databinding doesn' accept the
new value.


To populate the combo box:

cboPageMode.DataSource = Enum.GetValues(typeof(PageMode));


And for the data binding:

cboPageMode.DataBindings.Add("SelectedItem", _itemsDBS, "Mode");
 
B

Brian

Brian said:
Is there a way to bind a nullable Enum property to a combo box?

When choosing a value, and then leaving the combo box, the value reverts
back to the original value. It seems the databinding doesn' accept the
new value.


To populate the combo box:

cboPageMode.DataSource = Enum.GetValues(typeof(PageMode));


And for the data binding:

cboPageMode.DataBindings.Add("SelectedItem", _itemsDBS, "Mode");


I changed it to this, and it seems to work now:

cboPageMode.DataBindings.Add("SelectedItem", _itemsDBS,
"Mode", true,
System.Windows.Forms.DataSourceUpdateMode.OnValidation,
null);
 

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