473,413 Members | 1,679 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,413 software developers and data experts.

Combobox and Nullable Enum

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");
Jun 13 '06 #1
1 5998
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.OnValida tion,
null);
Jun 13 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: newbie | last post by:
Hello, I am using a propertygrid to allow users to edit\create objects at runtime, that can update records in a database. There are certain properties (fields) that I wish to display as...
7
by: gwenda | last post by:
I need a datasource for a third party combobox and the data should come from an enum. I have figured out how to use the enum to create a 2-dimensioned array imitating the form of Key, Value such...
27
by: Yuriy Solodkyy | last post by:
Hi VS 2005 beta 2 successfully compiles the following: using System; using System.Collections.Generic; using System.Text; namespace ConsoleApplication1 { class Program {
9
by: Don | last post by:
Is there any way to detect when an item has been added to the Items collection of a combobox or listbox? I am inheriting a Combobox and want to validate items before they are added to the...
30
by: dbuchanan | last post by:
ComboBox databindng Problem == How the ComboBox is setup and used: My comboBox is populated by a lookup table. The ValueMember is the lookup table's Id and the DisplayMember is the text from a...
3
by: Franky | last post by:
does anybody know how to use all values of an enumeration in a combobox? i have an enum type defined like public enum EnumTest { val1 = 1, val2 = 2, val4 = 4, }
1
by: NvrBst | last post by:
I have a dropdown list, then right now I simply call BGColorComboBox.DataSource = Enum.GetValues(typeof(KnownColor)); BGColorComboBox.SelectedItem = KnownColor.Black; Which works great except...
9
by: Cralis | last post by:
I have a List of data objects. I need to populate a ComboBox with the 'Description' field from the objects. I can do that with cmbBx.Items.Add( myObject.Description.ToString() ); myObject has 2...
1
by: CKKwan | last post by:
enum E = {a = 10, b = 10, c = 10}; object Value = 10; E? En = (E?)(int?)Value; Why do I need to caste it to (int?) before (E?) On the other hand, if it is not nullable, it doesn't request...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.