ホテル管理システム
ogi
yesterday 1a1c8e71fcd14858f595029f089b2d4a00202b32
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
76
77
78
79
80
81
82
83
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
 
namespace HotelPms.Share.Windows.Util
{
    public class ComboBoxItem
    {
        private string m_Key = string.Empty;
 
        public string Key
        {
            get { return m_Key; }
            set { m_Key = value; }
        }
 
        private string m_Text = string.Empty;
 
        public string Text
        {
            get { return m_Text; }
            set { m_Text = value; }
        }
 
        private object m_Tag = null;
 
        public object Tag
        {
            get { return m_Tag; }
            set { m_Tag = value; }
        }
 
        public ComboBoxItem(string key, string text)
        {
            this.m_Key = key;
            this.m_Text = text;
        }
 
        public override string ToString()
        {
            return m_Text;
        }
 
        public static void AddComboBox(ComboBox obj, Type type)
        {
            AddComboBox(obj, type, false, -1);
        }
 
        public static void AddComboBox(ComboBox obj, Type type, bool useBlank)
        {
            AddComboBox(obj, type, useBlank, -1);
        }
 
        public static void AddComboBox(ComboBox obj, Type type, bool useBlank, int defID)
        {
            int selIndex = 0;
            obj.Items.Clear();
            int i = 0;
            if (useBlank)
            {
                obj.Items.Add(new ComboBoxItem("-1", string.Empty));
                i++;
            }
 
            foreach (object item in Enum.GetValues(type))
            {
                int id = (int)item;
                string name = item.ToString();
                if (name.Contains("_"))
                {
                    string[] items = name.Split(new char[] { '_' });
                    if (items.Length == 2) { name = string.Format("{0}({1})", items[0], items[1]); }
                }
 
                obj.Items.Add(new ComboBoxItem(id.ToString(), name));
                if (id == defID) { selIndex = i; }
                i++;
            }
            obj.SelectedIndex = selIndex;
        }
    }
}