Brian A. Randell

Sleep, what's sleep?

<November 2008>
SuMoTuWeThFrSa
2627282930311
2345678
9101112131415
16171819202122
23242526272829
30123456


Navigation

Blogs I Read

Subscriptions

News

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2004,
Brian A. Randell.

About Me

Post Categories



Friday, June 18, 2004 - Posts

Data Binding an Enum to a Windows Forms ComboBox

Today someone posted on a list I'm on about how it would be cool if you could data bind an Enum to a ComboBox.

Well, you can. Assuming the following Enum:
Public Enum MyEnum
  [Me]
  Myself
  Irene
End Enum

You could use this code to bind it:
Me.ComboBox1.DataSource = System.Enum.GetValues(GetType(MyEnum))

Here's the code in C#:

public enum MyEnum
{
Me, MySelf, Irene
}

this.comboBox1.DataSource = System.Enum.GetValues(typeof(MyEnum));

Enjoy.

End of line.

posted Friday, June 18, 2004 8:28 AM by brianr




Powered by Dot Net Junkies, by Telligent Systems