1, 将枚举类型ViewType中所有值遍历,放到coboBox中
cbeType.Properties.Items.Clear();
cbeType.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.DisableTextEditor;
foreach (ViewType vt in Enum.GetValues(typeof(ViewType)))
{
cbeType.Properties.Items.Add(vt.ToString());
}
2,将coboBox 的某一个选中值转换成枚举型ViewType
private void cbeType_SelectedValueChanged(object sender, EventArgs e)
{
string sName = "";
if (!Common.IsNullOrEmpty(cbeType.SelectedItem))
{
sName = cbeType.SelectedItem.ToString();
ViewType tmp = (ViewType)(Enum.Parse(typeof(ViewType),sName));
BindData(tmp);//重新绑定数据
}
}