啊鑫
2024-10-25 cefcc903f51610846fa313a3a35bca34e129c1fe
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
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", "不正常"));
        }
 
        /// <summary>
        ///     显示值
        /// </summary>
        public string Txt
        {
            get => txt_isStatus.Text;
            set => _Text = value;
        }
 
        /// <summary>
        ///     对象值
        /// </summary>
        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();
        //}
    }
}