Home > Net >  The Grid in the drop-down box of an enum type to choose
The Grid in the drop-down box of an enum type to choose

Time:10-22

Is the corresponding value in the Grid column type is enumerated type
Editing is a drop-down selection box, how let the drop-down options displayed as the Description of an enum type value (that is, according to Chinese)

CodePudding user response:

 List ListCmbinfo=new List (a); 
Foreach (Type_e tt in Enum. GetValues (typeof (Type_e)))
{
ListCmbinfo. Add (new {Value=https://bbs.csdn.net/topics/tt, Desc=((DescriptionAttribute) Attribute. GetCustomAttribute (typeof (Type_e). GetField (tt) the ToString ()), typeof (DescriptionAttribute))). The Description});
}
Enclosing Column1. ValueMember="Value";
This. Column1. DisplayMember="Desc";
Enclosing Column1. The DataSource=listCmbinfo;
  •  Tags:  
  • C#
  • Related