How can I bind specific Enumto Combobox?
public enum EduTypePublicEnum
{
[RMSEnumItem("1", "Properties.Resources.SEduAlumn")]
Alumn,
[RMSEnumItem("2", "Properties.Resources.SEduProfesor")]
Profesor,
[RMSEnumItem("3", "Properties.Resources.SEduAll")]
All
}
public class EduTypePublic : RMSEnum<EduTypePublicEnum> { };
In my form
public EduAvisosForm()
{
InitializeComponent();
this.myComboBox.DataSource = Edu.Consts.EduTypePublic.Enums;
this.myComboBox.DisplayMember = "Alumn";
this.myComboBox.ValueMember = "Alumn";
}
But with ValueMemberor without an error, an error occurs. When I put this code without ValueMember, the error requesting ValueMemberwhen I put it does not work.
"Is not possible define SelectedValue in a ListControl with empty ValueMember"
public abstract class RMSEnum<TEnumType>
{
protected RMSEnum();
public static string CodeList { get; }
public static string[] Codes { get; }
public static string DescriptionList { get; }
public static string[] Descriptions { get; }
public static object[] Enums { get; }
public static string Code(TEnumType value);
public static string Description(string code);
public static string Description(TEnumType value);
public static TEnumType Enum(string code);
}
source
share