Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > .NET Languages
You last visited: Today at 08:09

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



C# ComboBox / Enum

Discussion on C# ComboBox / Enum within the .NET Languages forum part of the Coders Den category.

Reply
 
Old   #1

 
Nanoxx™'s Avatar
 
elite*gold: 15
Join Date: Feb 2013
Posts: 2,880
Received Thanks: 465
C# ComboBox / Enum

Moinsen,

Ich habe da ein kleines Problem, welches mich schon seit einiger Zeit beschäftigt

Code Beispiel:

PHP Code:
Combobox TestComBox = new Combobox();

public 
enum Test
{
TestA 45,
TestB 60,
TestC 90,
TestD 143,
TestE 222
}

void Main()
{
 
TestComBox.DataSource Enum.GetValues(typeof(Test));
}




void TestComBoxChanged()
{
DiesUndDas(TestComBox.SelectedItem) <-------- Enum -> Combobox -> Combobox.SelectedItem -> Enum 'Item'
}





void DiesUndDas(Test test)
{


Mir fällt da irgendwie keine Lösung ein....
Nanoxx™ is offline  
Old 11/19/2015, 09:03   #2
 
Biesi's Avatar
 
elite*gold: 0
Join Date: Jul 2010
Posts: 182
Received Thanks: 185


Code:
(Test)Enum.Parse(typeof(Test), TestComBox.SelectedItem);
Biesi is offline  
Thanks
1 User
Old 11/19/2015, 16:48   #3
 
elite*gold: 78
Join Date: Jul 2011
Posts: 457
Received Thanks: 887
Quote:
Originally Posted by Biesi View Post


Code:
(Test)Enum.Parse(typeof(Test), TestComBox.SelectedItem);
Einfacher wäre eine explizite Typkonvertierung ohne Enum.Parse, denn eine Enumeration ist im Grunde nichts anderes als ein konstanter Int32 Wert.
Code:
(Test)TestComBox.SelectedItem
Oder andersrum:
Code:
(int)test
MadnessFreak is offline  
Thanks
1 User
Reply


Similar Threads Similar Threads
ENUM 4STORY
12/01/2014 - 4Story - 15 Replies
I WANT ENGLISH FILES FOR ENUM 4STORY PLEASE TELL ME WHAT I CAN DO AND I WILL DO IT !!
[VB]Wie Combobox von Webbrowser in Combobox in Form hinzufügen
01/06/2014 - .NET Languages - 3 Replies
^Topic
C++ - Enum C2011 Error
02/22/2013 - C/C++ - 4 Replies
Hi, Ich wollte in C++ eine Enum in einer Headerdatei auslagern, aber wenn ich es Compilieren möchte erhalte ich nur: error C2011:'Punkte':'enum'Typneudefinition meine Enum sieht wie folgt aus: enum Punkte{ BONUSPUNKTE = 35, FULLHOUSEPUNKTE = 25,
[HELP] public enum
10/24/2009 - CO2 Private Server - 5 Replies
anyone here can help this? public enum UpdateID : uint { None = 0xFFFFFFFF, Hitpoints = 0, MaxHitpoints = 1, Mana = 2, MaxMana = 3, Money = 4, Experience = 5,



All times are GMT +1. The time now is 08:10.


Powered by vBulletin®
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2026 elitepvpers All Rights Reserved.