前提

入行已经7,8年了,一直想做一套漂亮点的自定义控件,于是就有了本系列文章。

开源地址:

如果觉得写的还行,请点个 star 支持一下吧

欢迎前来交流探讨: 企鹅群568015492 

目录

准备工作

此控件用到了停靠窗体和日期控件的一个面板,以及基类控件,如果你还对此不了解,请移步

(一)c#winform自定义控件-基类控件

(十九)c#winform自定义控件-停靠窗体

(三十三)c#winform自定义控件-日期控件

开始

添加一个用户控件,命名uccombobox,继承自uccontrolbase

属性

  1 color _forecolor = color.fromargb(64, 64, 64);
2         [description("文字颜色"), category("自定义")]
3         public override color forecolor
4         {
5             get
6             {
7                 return _forecolor;
8             }
9             set
10             {
11                 _forecolor = value;
12                 lblinput.forecolor = value;
13                 txtinput.forecolor = value;
14             }
15         }
16 
17         public event eventhandler selectedchangedevent;
18         public event eventhandler textchangedevent;
19 
20         private comboboxstyle _boxstyle = comboboxstyle.dropdown;
21 
22         [description("控件样式"), category("自定义")]
23         public comboboxstyle boxstyle
24         {
25             get { return _boxstyle; }
26             set
27             {
28                 _boxstyle = value;
29                 if (value == comboboxstyle.dropdownlist)
30                 {
31                     lblinput.visible = true;
32                     txtinput.visible = false;
33                 }
34                 else
35                 {
36                     lblinput.visible = false;
37                     txtinput.visible = true;
38                 }
39 
40                 if (this._boxstyle == comboboxstyle.dropdownlist)
41                 {
42                     txtinput.backcolor = _backcolor;
43                     base.fillcolor = _backcolor;
44                     base.rectcolor = _backcolor;
45                 }
46                 else
47                 {
48                     txtinput.backcolor = color.white;
49                     base.fillcolor = color.white;
50                     base.rectcolor = color.fromargb(220, 220, 220);
51                 }
52             }
53         }
54 
55         private font _font = new font("微软雅黑", 12);
56         [description("字体"), category("自定义")]
57         public new font font
58         {
59             get { return _font; }
60             set
61             {
62                 _font = value;
63                 lblinput.font = value;
64                 txtinput.font = value;
65                 txtinput.promptfont = value;
66                 this.txtinput.location = new point(this.txtinput.location.x, (this.height - txtinput.height) / 2);
67                 this.lblinput.location = new point(this.lblinput.location.x, (this.height - lblinput.height) / 2);
68             }
69         }
70 
71 
72         [obsolete("不再可用的属性")]
73         [browsable(false), editorbrowsable(editorbrowsablestate.never)]
74         private new color fillcolor
75         {
76             get;
77             set;
78         }
79 
80         [obsolete("不再可用的属性")]
81         [browsable(false), editorbrowsable(editorbrowsablestate.never)]
82         private new color rectcolor
83         {
84             get;
85             set;
86         }
87 
88         private string _textvalue;
89 
90         public string textvalue
91         {
92             get { return _textvalue; }
93             set
94             {
95                 _textvalue = value;
96                 if (lblinput.text != value)
97                     lblinput.text = value;
98                 if (txtinput.text != value)
99                     txtinput.text = value;
100             }
101         }
102 
103         private list<keyvaluepair<string, string>> _source = null;
104 
105         public list<keyvaluepair<string, string>> source
106         {
107             get { return _source; }
108             set
109             {
110                 _source = value;
111                 _selectedindex = -1;
112                 _selectedvalue = "";
113                 _selecteditem = new keyvaluepair<string, string>();
114                 _selectedtext = "";
115                 lblinput.text = "";
116                 txtinput.text = "";
117             }
118         }
119 
120         private keyvaluepair<string, string> _selecteditem = new keyvaluepair<string, string>();
121 
122         private int _selectedindex = -1;
123 
124         public int selectedindex
125         {
126             get
127             {
128                 return _selectedindex;
129             }
130             set
131             {
132                 if (value < 0 || _source == null || _source.count <= 0 || value >= _source.count)
133                 {
134                     _selectedindex = -1;
135                     _selectedvalue = "";
136                     _selecteditem = new keyvaluepair<string, string>();
137                     selectedtext = "";
138                 }
139                 else
140                 {
141                     _selectedindex = value;
142                     _selecteditem = _source[value];
143                     _selectedvalue = _source[value].key;
144                     selectedtext = _source[value].value;
145                 }
146             }
147         }
148 
149         private string _selectedvalue = "";
150 
151         public string selectedvalue
152         {
153             get
154             {
155                 return _selectedvalue;
156             }
157             set
158             {
159                 if (_source == null || _source.count <= 0)
160                 {
161                     selectedtext = "";
162                     _selectedvalue = "";
163                     _selectedindex = -1;
164                     _selecteditem = new keyvaluepair<string, string>();
165                 }
166                 else
167                 {
168                     for (int i = 0; i < _source.count; i++)
169                     {
170                         if (_source[i].key == value)
171                         {
172                             _selectedvalue = value;
173                             _selectedindex = i;
174                             _selecteditem = _source[i];
175                             selectedtext = _source[i].value;
176                             return;
177                         }
178                     }
179                     _selectedvalue = "";
180                     _selectedindex = -1;
181                     _selecteditem = new keyvaluepair<string, string>();
182                     selectedtext = "";
183                 }
184             }
185         }
186 
187         private string _selectedtext = "";
188 
189         public string selectedtext
190         {
191             get { return _selectedtext; }
192             private set
193             {
194                 _selectedtext = value;
195                 lblinput.text = _selectedtext;
196                 txtinput.text = _selectedtext;
197                 if (selectedchangedevent != null)
198                 {
199                     selectedchangedevent(this, null);
200                 }
201             }
202         }
203 
204         private int _itemwidth = 70;
205 
206         public int itemwidth
207         {
208             get { return _itemwidth; }
209             set { _itemwidth = value; }
210         }
211 
212         private int _droppanelheight = -1;
213 
214         public int droppanelheight
215         {
216             get { return _droppanelheight; }
217             set { _droppanelheight = value; }
218         }
219         [obsolete("不再可用的属性,如需要改变背景色,请使用backcolorext")]
220         [browsable(false), editorbrowsable(editorbrowsablestate.never)]
221         private new color backcolor
222         {
223             get
224             {
225                 return base.backcolor;
226             }
227             set
228             {
229                 base.backcolor = color.transparent;
230             }
231         }
232 
233         private color _backcolor = color.fromargb(240, 240, 240);
234 
235         public color backcolorext
236         {
237             get
238             {
239                 return _backcolor;
240             }
241             set
242             {
243                 if (value == color.transparent)
244                     return;
245                 _backcolor = value;
246                 lblinput.backcolor = value;
247 
248                 if (this._boxstyle == comboboxstyle.dropdownlist)
249                 {
250                     txtinput.backcolor = value;
251                     base.fillcolor = value;
252                     base.rectcolor = value;
253                 }
254                 else
255                 {
256                     txtinput.backcolor = color.white;
257                     base.fillcolor = color.white;
258                     base.rectcolor = color.fromargb(220, 220, 220);
259                 }
260             }
261         }

构造函数初始化处理

 1  public uccombobox()
2         {
3             initializecomponent();
4             lblinput.backcolor = _backcolor;
5             if (this._boxstyle == comboboxstyle.dropdownlist)
6             {
7                 txtinput.backcolor = _backcolor;
8                 base.fillcolor = _backcolor;
9                 base.rectcolor = _backcolor;
10             }
11             else
12             {
13                 txtinput.backcolor = color.white;
14                 base.fillcolor = color.white;
15                 base.rectcolor = color.fromargb(220, 220, 220);
16             }
17             base.backcolor = color.transparent;
18         }

一些事件处理

 1 private void uccombobox_sizechanged(object sender, eventargs e)
2         {
3             this.txtinput.location = new point(this.txtinput.location.x, (this.height - txtinput.height) / 2);
4             this.lblinput.location = new point(this.lblinput.location.x, (this.height - lblinput.height) / 2);
5         }
6 
7         private void txtinput_textchanged(object sender, eventargs e)
8         {
9             textvalue = txtinput.text;
10             if (textchangedevent != null)
11             {
12                 textchangedevent(this, null);
13             }
14         }
15 
16         private void click_mousedown(object sender, mouseeventargs e)
17         {
18             if (_frmanchor == null || _frmanchor.isdisposed || _frmanchor.visible == false)
19             {
20 
21                 if (this.source != null && this.source.count > 0)
22                 {
23                     int introw = 0;
24                     int intcom = 1;
25                     var p = this.pointtoscreen(this.location);
26                     while (true)
27                     {
28                         int intscreenheight = screen.primaryscreen.bounds.height;
29                         if ((p.y + this.height + this.source.count / intcom * 50 < intscreenheight || p.y - this.source.count / intcom * 50 > 0)
30                             && (_droppanelheight <= 0 ? true : (this.source.count / intcom * 50 <= _droppanelheight)))
31                         {
32                             introw = this.source.count / intcom + (this.source.count % intcom != 0 ? 1 : 0);
33                             break;
34                         }
35                         intcom++;
36                     }
37                     uctimepanel uctime = new uctimepanel();
38                     uctime.isshowborder = true;
39                     int intwidth = this.width / intcom;
40                     if (intwidth < _itemwidth)
41                         intwidth = _itemwidth;
42                     size size = new size(intcom * intwidth, introw * 50);
43                     uctime.size = size;
44                     uctime.firstevent = true;
45                     uctime.selectsourceevent += uctime_selectsourceevent;
46                     uctime.row = introw;
47                     uctime.column = intcom;
48                     list<keyvaluepair<string, string>> lst = new list<keyvaluepair<string, string>>();
49                     foreach (var item in this.source)
50                     {
51                         lst.add(new keyvaluepair<string, string>(item.key, item.value));
52                     }
53                     uctime.source = lst;
54 
55                     uctime.setselect(_selectedvalue);
56 
57                     _frmanchor = new forms.frmanchor(this, uctime);
58                     _frmanchor.load += (a, b) => { (a as form).size = size; };
59 
60                     _frmanchor.show(this.findform());
61 
62                 }
63             }
64             else
65             {
66                 _frmanchor.close();
67             }
68         }
69 
70 
71         forms.frmanchor _frmanchor;
72         void uctime_selectsourceevent(object sender, eventargs e)
73         {
74             if (_frmanchor != null && !_frmanchor.isdisposed && _frmanchor.visible)
75             {
76                 selectedvalue = sender.tostring();
77                 _frmanchor.close();
78             }
79         }
80 
81         private void uccombobox_load(object sender, eventargs e)
82         {
83             if (this._boxstyle == comboboxstyle.dropdownlist)
84             {
85                 txtinput.backcolor = _backcolor;
86                 base.fillcolor = _backcolor;
87                 base.rectcolor = _backcolor;
88             }
89             else
90             {
91                 txtinput.backcolor = color.white;
92                 base.fillcolor = color.white;
93                 base.rectcolor = color.fromargb(220, 220, 220);
94             }
95 
96             //if (this.parent != null && backcolor == color.transparent)
97         }
98     }
99 }

完整代码如下

  1 // 版权所有  黄正辉  交流群:568015492   qq:623128629
2 // 文件名称:uccombobox.cs
3 // 创建日期:2019-08-15 15:58:51
4 // 功能描述:combobox
5 // 项目地址:https://gitee.com/kwwwvagaa/net_winform_custom_control
6 using system;
7 using system.collections.generic;
8 using system.componentmodel;
9 using system.drawing;
10 using system.data;
11 using system.linq;
12 using system.text;
13 using system.windows.forms;
14 
15 namespace hzh_controls.controls
16 {
17     [defaultevent("selectedchangedevent")]
18     public partial class uccombobox : uccontrolbase
19     {
20         color _forecolor = color.fromargb(64, 64, 64);
21         [description("文字颜色"), category("自定义")]
22         public override color forecolor
23         {
24             get
25             {
26                 return _forecolor;
27             }
28             set
29             {
30                 _forecolor = value;
31                 lblinput.forecolor = value;
32                 txtinput.forecolor = value;
33             }
34         }
35 
36         public event eventhandler selectedchangedevent;
37         public event eventhandler textchangedevent;
38 
39         private comboboxstyle _boxstyle = comboboxstyle.dropdown;
40 
41         [description("控件样式"), category("自定义")]
42         public comboboxstyle boxstyle
43         {
44             get { return _boxstyle; }
45             set
46             {
47                 _boxstyle = value;
48                 if (value == comboboxstyle.dropdownlist)
49                 {
50                     lblinput.visible = true;
51                     txtinput.visible = false;
52                 }
53                 else
54                 {
55                     lblinput.visible = false;
56                     txtinput.visible = true;
57                 }
58 
59                 if (this._boxstyle == comboboxstyle.dropdownlist)
60                 {
61                     txtinput.backcolor = _backcolor;
62                     base.fillcolor = _backcolor;
63                     base.rectcolor = _backcolor;
64                 }
65                 else
66                 {
67                     txtinput.backcolor = color.white;
68                     base.fillcolor = color.white;
69                     base.rectcolor = color.fromargb(220, 220, 220);
70                 }
71             }
72         }
73 
74         private font _font = new font("微软雅黑", 12);
75         [description("字体"), category("自定义")]
76         public new font font
77         {
78             get { return _font; }
79             set
80             {
81                 _font = value;
82                 lblinput.font = value;
83                 txtinput.font = value;
84                 txtinput.promptfont = value;
85                 this.txtinput.location = new point(this.txtinput.location.x, (this.height - txtinput.height) / 2);
86                 this.lblinput.location = new point(this.lblinput.location.x, (this.height - lblinput.height) / 2);
87             }
88         }
89 
90 
91         [obsolete("不再可用的属性")]
92         [browsable(false), editorbrowsable(editorbrowsablestate.never)]
93         private new color fillcolor
94         {
95             get;
96             set;
97         }
98 
99         [obsolete("不再可用的属性")]
100         [browsable(false), editorbrowsable(editorbrowsablestate.never)]
101         private new color rectcolor
102         {
103             get;
104             set;
105         }
106 
107         private string _textvalue;
108 
109         public string textvalue
110         {
111             get { return _textvalue; }
112             set
113             {
114                 _textvalue = value;
115                 if (lblinput.text != value)
116                     lblinput.text = value;
117                 if (txtinput.text != value)
118                     txtinput.text = value;
119             }
120         }
121 
122         private list<keyvaluepair<string, string>> _source = null;
123 
124         public list<keyvaluepair<string, string>> source
125         {
126             get { return _source; }
127             set
128             {
129                 _source = value;
130                 _selectedindex = -1;
131                 _selectedvalue = "";
132                 _selecteditem = new keyvaluepair<string, string>();
133                 _selectedtext = "";
134                 lblinput.text = "";
135                 txtinput.text = "";
136             }
137         }
138 
139         private keyvaluepair<string, string> _selecteditem = new keyvaluepair<string, string>();
140 
141         private int _selectedindex = -1;
142 
143         public int selectedindex
144         {
145             get
146             {
147                 return _selectedindex;
148             }
149             set
150             {
151                 if (value < 0 || _source == null || _source.count <= 0 || value >= _source.count)
152                 {
153                     _selectedindex = -1;
154                     _selectedvalue = "";
155                     _selecteditem = new keyvaluepair<string, string>();
156                     selectedtext = "";
157                 }
158                 else
159                 {
160                     _selectedindex = value;
161                     _selecteditem = _source[value];
162                     _selectedvalue = _source[value].key;
163                     selectedtext = _source[value].value;
164                 }
165             }
166         }
167 
168         private string _selectedvalue = "";
169 
170         public string selectedvalue
171         {
172             get
173             {
174                 return _selectedvalue;
175             }
176             set
177             {
178                 if (_source == null || _source.count <= 0)
179                 {
180                     selectedtext = "";
181                     _selectedvalue = "";
182                     _selectedindex = -1;
183                     _selecteditem = new keyvaluepair<string, string>();
184                 }
185                 else
186                 {
187                     for (int i = 0; i < _source.count; i++)
188                     {
189                         if (_source[i].key == value)
190                         {
191                             _selectedvalue = value;
192                             _selectedindex = i;
193                             _selecteditem = _source[i];
194                             selectedtext = _source[i].value;
195                             return;
196                         }
197                     }
198                     _selectedvalue = "";
199                     _selectedindex = -1;
200                     _selecteditem = new keyvaluepair<string, string>();
201                     selectedtext = "";
202                 }
203             }
204         }
205 
206         private string _selectedtext = "";
207 
208         public string selectedtext
209         {
210             get { return _selectedtext; }
211             private set
212             {
213                 _selectedtext = value;
214                 lblinput.text = _selectedtext;
215                 txtinput.text = _selectedtext;
216                 if (selectedchangedevent != null)
217                 {
218                     selectedchangedevent(this, null);
219                 }
220             }
221         }
222 
223         private int _itemwidth = 70;
224 
225         public int itemwidth
226         {
227             get { return _itemwidth; }
228             set { _itemwidth = value; }
229         }
230 
231         private int _droppanelheight = -1;
232 
233         public int droppanelheight
234         {
235             get { return _droppanelheight; }
236             set { _droppanelheight = value; }
237         }
238         [obsolete("不再可用的属性,如需要改变背景色,请使用backcolorext")]
239         [browsable(false), editorbrowsable(editorbrowsablestate.never)]
240         private new color backcolor
241         {
242             get
243             {
244                 return base.backcolor;
245             }
246             set
247             {
248                 base.backcolor = color.transparent;
249             }
250         }
251 
252         private color _backcolor = color.fromargb(240, 240, 240);
253 
254         public color backcolorext
255         {
256             get
257             {
258                 return _backcolor;
259             }
260             set
261             {
262                 if (value == color.transparent)
263                     return;
264                 _backcolor = value;
265                 lblinput.backcolor = value;
266 
267                 if (this._boxstyle == comboboxstyle.dropdownlist)
268                 {
269                     txtinput.backcolor = value;
270                     base.fillcolor = value;
271                     base.rectcolor = value;
272                 }
273                 else
274                 {
275                     txtinput.backcolor = color.white;
276                     base.fillcolor = color.white;
277                     base.rectcolor = color.fromargb(220, 220, 220);
278                 }
279             }
280         }
281 
282         public uccombobox()
283         {
284             initializecomponent();
285             lblinput.backcolor = _backcolor;
286             if (this._boxstyle == comboboxstyle.dropdownlist)
287             {
288                 txtinput.backcolor = _backcolor;
289                 base.fillcolor = _backcolor;
290                 base.rectcolor = _backcolor;
291             }
292             else
293             {
294                 txtinput.backcolor = color.white;
295                 base.fillcolor = color.white;
296                 base.rectcolor = color.fromargb(220, 220, 220);
297             }
298             base.backcolor = color.transparent;
299         }
300 
301         private void uccombobox_sizechanged(object sender, eventargs e)
302         {
303             this.txtinput.location = new point(this.txtinput.location.x, (this.height - txtinput.height) / 2);
304             this.lblinput.location = new point(this.lblinput.location.x, (this.height - lblinput.height) / 2);
305         }
306 
307         private void txtinput_textchanged(object sender, eventargs e)
308         {
309             textvalue = txtinput.text;
310             if (textchangedevent != null)
311             {
312                 textchangedevent(this, null);
313             }
314         }
315 
316         private void click_mousedown(object sender, mouseeventargs e)
317         {
318             if (_frmanchor == null || _frmanchor.isdisposed || _frmanchor.visible == false)
319             {
320 
321                 if (this.source != null && this.source.count > 0)
322                 {
323                     int introw = 0;
324                     int intcom = 1;
325                     var p = this.pointtoscreen(this.location);
326                     while (true)
327                     {
328                         int intscreenheight = screen.primaryscreen.bounds.height;
329                         if ((p.y + this.height + this.source.count / intcom * 50 < intscreenheight || p.y - this.source.count / intcom * 50 > 0)
330                             && (_droppanelheight <= 0 ? true : (this.source.count / intcom * 50 <= _droppanelheight)))
331                         {
332                             introw = this.source.count / intcom + (this.source.count % intcom != 0 ? 1 : 0);
333                             break;
334                         }
335                         intcom++;
336                     }
337                     uctimepanel uctime = new uctimepanel();
338                     uctime.isshowborder = true;
339                     int intwidth = this.width / intcom;
340                     if (intwidth < _itemwidth)
341                         intwidth = _itemwidth;
342                     size size = new size(intcom * intwidth, introw * 50);
343                     uctime.size = size;
344                     uctime.firstevent = true;
345                     uctime.selectsourceevent += uctime_selectsourceevent;
346                     uctime.row = introw;
347                     uctime.column = intcom;
348                     list<keyvaluepair<string, string>> lst = new list<keyvaluepair<string, string>>();
349                     foreach (var item in this.source)
350                     {
351                         lst.add(new keyvaluepair<string, string>(item.key, item.value));
352                     }
353                     uctime.source = lst;
354 
355                     uctime.setselect(_selectedvalue);
356 
357                     _frmanchor = new forms.frmanchor(this, uctime);
358                     _frmanchor.load += (a, b) => { (a as form).size = size; };
359 
360                     _frmanchor.show(this.findform());
361 
362                 }
363             }
364             else
365             {
366                 _frmanchor.close();
367             }
368         }
369 
370 
371         forms.frmanchor _frmanchor;
372         void uctime_selectsourceevent(object sender, eventargs e)
373         {
374             if (_frmanchor != null && !_frmanchor.isdisposed && _frmanchor.visible)
375             {
376                 selectedvalue = sender.tostring();
377                 _frmanchor.close();
378             }
379         }
380 
381         private void uccombobox_load(object sender, eventargs e)
382         {
383             if (this._boxstyle == comboboxstyle.dropdownlist)
384             {
385                 txtinput.backcolor = _backcolor;
386                 base.fillcolor = _backcolor;
387                 base.rectcolor = _backcolor;
388             }
389             else
390             {
391                 txtinput.backcolor = color.white;
392                 base.fillcolor = color.white;
393                 base.rectcolor = color.fromargb(220, 220, 220);
394             }
395         }
396     }
397 }
  1 namespace hzh_controls.controls
2 {
3     partial class uccombobox
4     {
5         /// <summary> 
6         /// 必需的设计器变量。
7         /// </summary>
8         private system.componentmodel.icontainer components = null;
9 
10         /// <summary> 
11         /// 清理所有正在使用的资源。
12         /// </summary>
13         /// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
14         protected override void dispose(bool disposing)
15         {
16             if (disposing && (components != null))
17             {
18                 components.dispose();
19             }
20             base.dispose(disposing);
21         }
22 
23         #region 组件设计器生成的代码
24 
25         /// <summary> 
26         /// 设计器支持所需的方法 - 不要
27         /// 使用代码编辑器修改此方法的内容。
28         /// </summary>
29         private void initializecomponent()
30         {
31             this.panel1 = new system.windows.forms.panel();
32             this.txtinput = new hzh_controls.controls.textboxex();
33             this.lblinput = new system.windows.forms.label();
34             this.suspendlayout();
35             // 
36             // panel1
37             // 
38             this.panel1.backcolor = system.drawing.color.transparent;
39             this.panel1.backgroundimage = global::hzh_controls.properties.resources.combobox;
40             this.panel1.backgroundimagelayout = system.windows.forms.imagelayout.center;
41             this.panel1.dock = system.windows.forms.dockstyle.right;
42             this.panel1.location = new system.drawing.point(136, 0);
43             this.panel1.name = "panel1";
44             this.panel1.size = new system.drawing.size(37, 32);
45             this.panel1.tabindex = 0;
46             this.panel1.mousedown += new system.windows.forms.mouseeventhandler(this.click_mousedown);
47             // 
48             // txtinput
49             // 
50             this.txtinput.anchor = ((system.windows.forms.anchorstyles)((system.windows.forms.anchorstyles.left | system.windows.forms.anchorstyles.right)));
51             this.txtinput.backcolor = system.drawing.color.white;
52             this.txtinput.borderstyle = system.windows.forms.borderstyle.none;
53             this.txtinput.declength = 2;
54             this.txtinput.font = new system.drawing.font("微软雅黑", 18f, system.drawing.fontstyle.regular, system.drawing.graphicsunit.pixel);
55             this.txtinput.forecolor = system.drawing.color.fromargb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
56             this.txtinput.inputtype = textinputtype.notcontrol;
57             this.txtinput.location = new system.drawing.point(3, 4);
58             this.txtinput.margin = new system.windows.forms.padding(3, 3, 10, 3);
59             this.txtinput.maxvalue = new decimal(new int[] {
60             1000000,
61             0,
62             0,
63             0});
64             this.txtinput.minvalue = new decimal(new int[] {
65             1000000,
66             0,
67             0,
68             -2147483648});
69             this.txtinput.myrectangle = new system.drawing.rectangle(0, 0, 0, 0);
70             this.txtinput.name = "txtinput";
71             this.txtinput.oldtext = null;
72             this.txtinput.promptcolor = system.drawing.color.silver;
73             this.txtinput.promptfont = new system.drawing.font("微软雅黑", 15f, system.drawing.fontstyle.regular, system.drawing.graphicsunit.pixel);
74             this.txtinput.prompttext = "";
75             this.txtinput.regexpattern = "";
76             this.txtinput.size = new system.drawing.size(133, 24);
77             this.txtinput.tabindex = 1;
78             this.txtinput.textchanged += new system.eventhandler(this.txtinput_textchanged);
79             // 
80             // lblinput
81             // 
82             this.lblinput.autosize = true;
83             this.lblinput.forecolor = system.drawing.color.fromargb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
84             this.lblinput.location = new system.drawing.point(3, 6);
85             this.lblinput.name = "lblinput";
86             this.lblinput.size = new system.drawing.size(0, 20);
87             this.lblinput.tabindex = 2;
88             this.lblinput.visible = false;
89             this.lblinput.mousedown += new system.windows.forms.mouseeventhandler(this.click_mousedown);
90             // 
91             // uccombobox
92             // 
93             this.autoscalemode = system.windows.forms.autoscalemode.none;
94             this.backcolor = system.drawing.color.transparent;
95             this.conerradius = 5;
96             this.controls.add(this.panel1);
97             this.controls.add(this.txtinput);
98             this.controls.add(this.lblinput);
99             this.fillcolor = system.drawing.color.gainsboro;
100             this.isshowrect = true;
101             this.name = "uccombobox";
102             this.size = new system.drawing.size(173, 32);
103             this.load += new system.eventhandler(this.uccombobox_load);
104             this.sizechanged += new system.eventhandler(this.uccombobox_sizechanged);
105             this.mousedown += new system.windows.forms.mouseeventhandler(this.click_mousedown);
106             this.resumelayout(false);
107             this.performlayout();
108 
109         }
110 
111         #endregion
112 
113         private system.windows.forms.panel panel1;
114         public textboxex txtinput;
115         private system.windows.forms.label lblinput;
116     }
117 }

用处及效果

最后的话

如果你喜欢的话,请到  点个星 星吧