PC Review


Reply
Thread Tools Rate Thread

Combobox and Nullable Enum

 
 
Brian
Guest
Posts: n/a
 
      13th Jun 2006
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");
 
Reply With Quote
 
 
 
 
Brian
Guest
Posts: n/a
 
      13th Jun 2006
Brian wrote:
> 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);
 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Nullable Enum Vikas Manghani Microsoft C# .NET 2 20th Feb 2009 05:53 AM
Nullable Enum Vikas Manghani Microsoft C# .NET 0 11th Feb 2009 11:53 AM
Nullable Enum Vikas Manghani Microsoft C# .NET 0 11th Feb 2009 06:09 AM
Nullable Enum Vikas Manghani Microsoft C# .NET 0 11th Feb 2009 05:55 AM
Nullable Enum Vikas Manghani Microsoft C# .NET 0 11th Feb 2009 05:52 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:40 AM.