ホテル管理システム
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
 
namespace HotelPms.Share.Windows.Component
{
    public static class ControlEx
    {
        /// <summary>
        /// コントロールの拡張プロパティメソッド追加
        /// </summary>
        /// <param name="self"></param>
        /// <returns></returns>
        public static object GetPropertyEx(this Control self, string key)
        {
            ControlPropertyEx val = null;
            ControlPropertyEx.Data.TryGetValue(self, out val);
            return val.Addition[key];
        }
 
        public static void SetPropertyEx(this Control self, string key, object value)
        {
            ControlPropertyEx data = null;
            if(!ControlPropertyEx.Data.TryGetValue(self, out data))
            {
                data = new ControlPropertyEx();
                ControlPropertyEx.Data.Add(self, data);
            }
            data.Addition[key] = value;  //存在しなかったら、自動追加
        }
 
 
        public static ControlPropertyEx GetPropertyData(this Control self)
        {
            ControlPropertyEx val = null;
            ControlPropertyEx.Data.TryGetValue(self, out val);
            return val;
        }
    }
}