Short summery about data binding with enum description

Sunday, May 30, 2010

This is fact that every time binding is required to itemized windows forms control, usually a Combo Box. You will find lots of editorial chapters on code project to make certain kind of changes. These all chapters are with different cons and pros. If you check the coding they are little bit complicated then it require. Through some of the code projects more efforts are required by the developers to implement the enum.

Those who know the usage of Enum.GetValues () method can make the coding easy.

Binding with explanation: there are many other ways to meet the requirement the only thing you have to do is little bit reflection in enum values with attribute. Keep one thing in mind that a lot of generic classes, custom classes, or custom type descriptors are not required. The changes are possible with two static methods less than 10 lines of codes. The initial step required is to add a description attribute to enum. To make the coding simple you can use DescriptionAttribute class. However, we will commend developing own EnumDescriptionAttribute by developers. If you are using the custom attribute there you will find the human readable description where the enum is defined. Another feature of this description is it will allow you to retrieve restricted editions of description. To follow the order you have to change the attribute works to search for string in string resources.

Next part you need to care about is what actually does all of work? We have already discussed that simple coding will be less than 10 lines of code.  If you are not using .net 2.0 or later version then you should work static class which will hold the two static functions.

Keep one thing in mind that GetDescription method uses small amount of reflection to retrieve the enum value.


 
We prefer Bluehost Hosting
 
Text Space Available
Your Text
www.Domain.com
Posicionamiento Web Mexico
Servicios: SEO, Marketing en Internet, Google Adwords y Optimizacion Web
www.SEOwebMexico.com

WooThemes - WordPress themes for everyone

Quick Links
Our Friends
Cool Places
Visit also
About Us