Advertisement
Guest User

Untitled

a guest
Apr 16th, 2014
31
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.39 KB | None | 0 0
  1. public enum EduTypePublicEnum
  2. {
  3. [RMSEnumItem("1", "Properties.Resources.SEduAlumn")]
  4. Alumn,
  5. [RMSEnumItem("2", "Properties.Resources.SEduProfesor")]
  6. Profesor,
  7. [RMSEnumItem("3", "Properties.Resources.SEduAll")]
  8. All
  9. }
  10.  
  11. public class EduTypePublic : RMSEnum<EduTypePublicEnum> { };
  12.  
  13. public EduAvisosForm()
  14. {
  15. InitializeComponent();
  16.  
  17. this.myComboBox.DataSource = Edu.Consts.EduTypePublic.Enums;
  18. this.myComboBox.DisplayMember = "Alumn";
  19. this.myComboBox.ValueMember = "Alumn";
  20. }
  21.  
  22. public abstract class RMSEnum<TEnumType>
  23. {
  24. protected RMSEnum();
  25.  
  26. public static string CodeList { get; }
  27. public static string[] Codes { get; }
  28. public static string DescriptionList { get; }
  29. public static string[] Descriptions { get; }
  30. public static object[] Enums { get; }
  31.  
  32. public static string Code(TEnumType value);
  33. public static string Description(string code);
  34. public static string Description(TEnumType value);
  35. public static TEnumType Enum(string code);
  36. }
  37.  
  38. this.myComboBox.DisplayMember = "Value";
  39. this.myComboBox.ValueMember = "Key";
  40. this.myComboBox.DataSource =
  41. Enum.GetValues(typeof(EduTypePublicEnum))
  42. .Cast<EduTypePublicEnum>()
  43. .Select(e => new {
  44. Key = e.ToString(), // possibly read localized string
  45. Value = e
  46. }).ToList();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement