using DevExpress.XtraEditors; using Gs.DevApp.ToolBox; namespace Gs.DevApp.UserControl { public partial class UcComBox : XtraUserControl { private string _Text = "-请选择-"; private string _Value = "0"; public UcComBox() { InitializeComponent(); txt_isStatus.Properties.Items.Add(new CboItemEntity("", "-请选择-")); txt_isStatus.Properties.Items.Add(new CboItemEntity("1", "正常")); txt_isStatus.Properties.Items.Add(new CboItemEntity("-1", "不正常")); } /// /// 显示值 /// public string Txt { get => txt_isStatus.Text; set => _Text = value; } /// /// 对象值 /// public string Val { get { switch (txt_isStatus.SelectedIndex) { case 0: return "0"; case 1: return "1"; case 2: return "-1"; default: return "0"; } } set { _Value = value; if (!string.IsNullOrEmpty(value)) switch (int.Parse(value)) { case 0: txt_isStatus.SelectedIndex = 0; break; case 1: txt_isStatus.SelectedIndex = 1; break; case -1: txt_isStatus.SelectedIndex = 2; break; default: txt_isStatus.SelectedIndex = 0; break; } } } //public override string ToString() //{ // return this.Text.ToString(); //} } }