Search
Categories
  ASP.NET
Visual C#
Visual Basic
.NET Framework
ADO.NET
AJAX
LINQ
Java
 
How To Rating
 
0.0 out of 5


Total Votes: 0
         
1 2 3 4 5
 




How to bind enum with ComboBox Control in C#

Author: Waqas Anwar - Posted Date: 07-September-2009 - Category: Visual C#   
Bookmark and Share
You have created an enum in C# and you want to bind the enum with the data bound controls such as ComboBox control. You can use GetValues() method of Enum class for this purpose as shown below:
public enum WeekDays
{
   Mon, Tue, Wed, Thu, Fri, Sat, Sun
}

To bind the above enum with ComboBox control use the following:
comboBox1.DataSource = Enum.GetValues(typeof(WeekDays));


RELATED HOW TOs

  How to Create Enum in C#

LEAVE YOUR COMMENTS LEAVE YOUR COMMENTS
 Name (required)  
 Email (required
 Website


 

 


 
 
 

Categories

My Portfolio

Website Links


Copyright @ 2009 EzzyLearning.com