Posted By

Maikel on 05/04/11


Tagged

enum


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

ovuncgursoy


Bind Enum to Combobox


 / Published in: C#
 

  1. var query = (from int n in Enum.GetValues(typeof(System.Windows.Forms.DialogResult))
  2. select new {
  3. n,
  4. Key = Enum.GetName(typeof(System.Windows.Forms.DialogResult),n)
  5. }
  6. );
  7.  
  8. comboBox1.DataSource = query.ToList();
  9. comboBox1.DisplayMember = "key";
  10. comboBox1.ValueMember = "n";

Report this snippet  

You need to login to post a comment.