Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

c# binding add combobox with enum values

public class DataItem
{
    public MyEnum Value { get; set; }
    public string Text { get; set; }
}

this.comboBox1.DataSource = Enum.GetValues(typeof(MyEnum)).Cast<MyEnum>()
                                .Select(x => new DataItem() { Value = x, Text = x.ToString() })
                                .ToList();
this.comboBox1.ValueMember = "Value";
this.comboBox1.DisplayMember = "Text";

this.comboBox1.DataBindings.Add(
    new Binding("SelectedValue", yourObjectToBind, "PropertyOfYourObject"));
Comment

PREVIOUS NEXT
Code Example
Csharp :: c# list foreach 
Csharp :: datetime empty date 
Csharp :: c# copy files from one folder to another 
Csharp :: ternary operator in c# 
Csharp :: c# char 
Csharp :: asp.net mvc get current url in view 
Csharp :: c# enum 
Csharp :: c# new list of objects 
Csharp :: unity c# struct 
Csharp :: unity sort a list 
Csharp :: how get data from json in c# 
Csharp :: c# get process file location 
Csharp :: c# swap name in string 
Csharp :: how to get current dir in c# 
Csharp :: c# get gridview DataKeyNames 
Csharp :: Get the Photon Player GameObject 
Csharp :: windows forms get all images from resources 
Csharp :: Hello World Dotnet 
Csharp :: c# backup sql 
Csharp :: make 2D object move at constant speed unity 
Csharp :: yield c# 
Csharp :: c# read double 
Csharp :: initialize a char array java 
Csharp :: destroy gameobject with tag unity 
Csharp :: rotate along normal unity 
Csharp :: unity scroll rect to bottom 
Csharp :: c# bool to int 
Csharp :: SieveOfEratosthenes 
Csharp :: search for a substring in the registry 
Csharp :: print c# 
ADD CONTENT
Topic
Content
Source link
Name
3+3 =