473,326 Members | 2,126 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,326 software developers and data experts.

enum and combobox

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,
}

i would like to bind this to a combobox so that i can use 'val1' als the
displaymember of the combobox and the int as the valuemember.

any ideas?

thanks,
Dries
Dec 19 '05 #1
3 9789
Franky

You can use Enum.GetNames to return the constants used. Also, use
Enum.GetValues to return the values.

Use a loop to iterate over and assign to your combobox.

Mark

"Franky" <dr***@bestopia.be> wrote in message
news:11***************@seven.kulnet.kuleuven.ac.be ...
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,
}

i would like to bind this to a combobox so that i can use 'val1' als the
displaymember of the combobox and the int as the valuemember.

any ideas?

thanks,
Dries

Dec 19 '05 #2
> Use a loop to iterate over and assign to your > combobox.

I think it can be done without the loop.
Look it up in the docs.
Roger
Dec 19 '05 #3
Yes, as long as it supports the IList interface, you can just databind the
array that is returned to the combobox.

Mark

"Roger" <ro***@pcsrevenuecontrol.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Use a loop to iterate over and assign to your > combobox.


I think it can be done without the loop.
Look it up in the docs.
Roger

Dec 19 '05 #4

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

Similar topics

2
by: Cody Manix | last post by:
is there a way to explicitly assign a name to an enum member? what about internationalisation? one must be able to change the text. i'd like to implemtent it this way: enum Color = {...
3
by: frivard | last post by:
I have a Enum named "Status" with elements like public enum Status : int { T = 82, C = 67, } I want to display de content of this Enum in a combobox. In my combobox i want the ...
2
by: Rene | last post by:
Say that I create a combobox with pull down items that map directly to an enum. For example the dropdown items could be "Up", "Down", "Left" and "Right" and the enum could be declare as: public...
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...
3
by: cyshao | last post by:
Hi ,my friends: I have a enum type ,EMyEnum , defigned as . I just want to do something like this: foreach( EMyEnum crrEnum in EMyEnum ) { //do something }
7
by: Harris | last post by:
Dear all, I have the following codes: ====== public enum Enum_Value { Value0 = 0, Value1 = 10,
3
by: Desmond Cassidy | last post by:
I created an Enum with the EnumBuilder which allows you to add items with spaces embedded as well as the name of the Enum. e.g. US States and a member of New York The normal way you would iterate...
5
by: kjqua | last post by:
Hi all, I am newbie in c# and i have a question. I try to work with serial port. and i will like to configure the serial port by a form I add in a ComboBox.parity some items like: None Odd
1
by: Gerrit | last post by:
Hello, I have an enum, example: enum MyEnum { My_Value_1, My_Value_2 }
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.