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