`
saybody
  • 浏览: 871145 次
  • 性别: Icon_minigender_2
  • 来自: 西安
文章分类
社区版块
存档分类
最新评论

C#基础系列:开发自己的窗体设计器(实现控件的选择)

阅读更多

所谓控件的选择,就是在设计器上某个控件被选中或者控件获得焦点(通过Tab调整控件焦点)的时候,在控件的四周显示出调整手柄。

如下图:

如上,通过控件的调整手柄,我们可以调整控件的宽度和高度。而实现这个调整手柄的关键点其实得益于vs2005控件的灵活性。因为这8个正方形的调整手柄其实就是8个控件。

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

所以我们本文的重点如下:

1、开发自定义的调整手柄控件,也就是这正方形控件;

2、组合这8个调整手柄控件,目标是使设计器上的控件与调整手柄完全解耦,调整手柄能够不做任何的修改就可以应用于所有的控件;

3、设计器上的控件与调整手柄的对应方法,也就是选择控件的时候,能够在控件周围显示调整手柄。

下面我们针对这3个重点,在前一篇《在容器上拖动鼠标增加控件》的基础上,实现控件的选择功能。

1、开发自定义的调整手柄控件:

这其实属于自定义控件开发的问题,你首先增加“用户控件”,把控件名命名为UISizeDot,把下面的代码直接拷贝进去就可以了,所以我不做过多的描述,这里直接把代码贴出来好了。

  1. [ToolboxItem(false)]
  2. publicpartialclassUISizeDot:Control
  3. {
  4. privatebool_movable;
  5. privatePenpen=newPen(Color.Black);
  6. publicUISizeDot()
  7. {
  8. InitializeComponent();
  9. SetStyle(ControlStyles.UserPaint,true);
  10. SetStyle(ControlStyles.AllPaintingInWmPaint,true);
  11. SetStyle(ControlStyles.OptimizedDoubleBuffer,true);
  12. this.TabStop=false;
  13. this._movable=true;
  14. }
  15. ///<summary>
  16. ///UISizeDot的边框颜色
  17. ///</summary>
  18. publicColorBorderColor
  19. {
  20. get{returnpen.Color;}
  21. set
  22. {
  23. this.pen=newPen(value);
  24. this.Refresh();
  25. }
  26. }
  27. protectedoverridevoidOnPaint(PaintEventArgspe)
  28. {
  29. //TODO:在此处添加自定义绘制代码
  30. //this.BackColor=Color.White;
  31. pe.Graphics.DrawRectangle(pen,0,0,this.Width-1,this.Height-1);
  32. //调用基类OnPaint
  33. base.OnPaint(pe);
  34. }
  35. publicboolMovable
  36. {
  37. get{returnthis._movable;}
  38. set{this._movable=value;}
  39. }
  40. }

2、组合这8个自定义调整手柄控件:

这个功能的目的就是,就是将这8个调整手柄控件组合起来,为了描述以及开发上的方便,我们使用一个控件数组UISizeDot[]_UISizeDot = new UISizeDot(8),我们约定从左上角按照顺时针方向到又下角分别_UISizeDot[0]~ _UISizeDot[7],其它的不用说了,看代码吧:

  1. publicenumENUM_UISizeMode
  2. {
  3. FixNone=0,//不固定
  4. FixLocation=1,//固定左上角,这时只能改变两边
  5. FixHeight=2,//固定高
  6. FixWidth=3,//固定宽
  7. FixBoth=4//长宽都固定
  8. }
  9. publicclassUISizeKnob
  10. {
  11. privateconstintDOT_WIDTH=7;//UISizeDot宽度
  12. privateconstintDOT_HEIGHT=7;//UISizeDot高度
  13. privateconstintDOT_SPACE=0;//UISizeDot与_Owner的距离
  14. privateconstintDOT_COUNT=8;//要显示的UISizeDot数
  15. privateSystem.Windows.Forms.Control_Owner;
  16. privateUISizeDot[]_UISizeDot;
  17. privateint_OldTop;
  18. privateint_OldLeft;
  19. privateint_NewTop;
  20. privateint_NewLeft;
  21. privateint_OldWidth;
  22. privateint_OldHeight;
  23. privateint_ClickAtX;
  24. privateint_ClickAtY;
  25. privateENUM_UISizeMode_UISizeMode;
  26. privatebool_BeginDrag;
  27. privateRectangle_OldRect;
  28. privateColor_DotColor=Color.White;//UISizeDot默认颜色为白色
  29. privateColor_DotBorderColor=Color.Black;//UISizeDot默认边框颜色为黑色
  30. publiceventSystem.Windows.Forms.MouseEventHandlerMouseDown=null;
  31. publiceventSystem.Windows.Forms.MouseEventHandlerMouseMove=null;
  32. publiceventSystem.Windows.Forms.MouseEventHandlerMouseUp=null;
  33. privateintj=0;
  34. privatebool_IsShow=false;
  35. publicUISizeKnob(System.Windows.Forms.Controlowner)
  36. {
  37. this._Owner=owner;
  38. this._NewTop=owner.Top;
  39. this._NewLeft=owner.Left;
  40. this._OldWidth=owner.Width;
  41. this._OldHeight=owner.Height;
  42. InitUISizeDots();
  43. }
  44. publicboolIsShow
  45. {
  46. get{returnthis._IsShow;}
  47. }
  48. publicColorDotColor
  49. {
  50. get{returnthis._DotColor;}
  51. set
  52. {
  53. this._DotColor=value;
  54. this._DotBorderColor=Color.FromArgb(Math.Abs(Convert.ToInt32(value.R)-255),Math.Abs(Convert.ToInt32(value.G)-255),Math.Abs(Convert.ToInt32(value.B)-255));
  55. }
  56. }
  57. ///<summary>
  58. ///注销
  59. ///</summary>
  60. publicvoidDispose()
  61. {
  62. for(inti=0;i<this._UISizeDot.Length;i++)
  63. {
  64. this._UISizeDot[i].Dispose();
  65. }
  66. }
  67. ///<summary>
  68. ///this._Owner的大小改变模式
  69. ///</summary>
  70. publicENUM_UISizeModeUISizeMode
  71. {
  72. get{returnthis._UISizeMode;}
  73. set{this._UISizeMode=value;}
  74. }
  75. privatevoidInitUISizeDots()
  76. {
  77. this._UISizeDot=newUISizeDot[DOT_COUNT];
  78. for(inti=0;i<DOT_COUNT;i++)
  79. {
  80. this._UISizeDot[i]=newUISizeDot();
  81. this._UISizeDot[i].Width=DOT_WIDTH;
  82. this._UISizeDot[i].Height=DOT_HEIGHT;
  83. this._UISizeDot[i].Visible=false;
  84. this._Owner.Parent.Controls.Add(this._UISizeDot[i]);
  85. this._UISizeDot[i].MouseDown+=newSystem.Windows.Forms.MouseEventHandler(this.UISizeDot_MouseDown);
  86. this._UISizeDot[i].MouseMove+=newSystem.Windows.Forms.MouseEventHandler(this.UISizeDot_MouseMove);
  87. this._UISizeDot[i].MouseUp+=newSystem.Windows.Forms.MouseEventHandler(this.UISizeDot_MouseUp);
  88. }
  89. this._UISizeDot[0].Cursor=System.Windows.Forms.Cursors.SizeNWSE;
  90. this._UISizeDot[1].Cursor=System.Windows.Forms.Cursors.SizeNS;
  91. this._UISizeDot[2].Cursor=System.Windows.Forms.Cursors.SizeNESW;
  92. this._UISizeDot[3].Cursor=System.Windows.Forms.Cursors.SizeWE;
  93. this._UISizeDot[4].Cursor=System.Windows.Forms.Cursors.SizeNWSE;
  94. this._UISizeDot[5].Cursor=System.Windows.Forms.Cursors.SizeNS;
  95. this._UISizeDot[6].Cursor=System.Windows.Forms.Cursors.SizeNESW;
  96. this._UISizeDot[7].Cursor=System.Windows.Forms.Cursors.SizeWE;
  97. SetUISizeDotsPosition();
  98. }
  99. publicvoidShowUISizeDots(boolshow)
  100. {
  101. this._IsShow=show;
  102. //2006-10-05:将此函数中所有的this._UISizeDot.Length全部替换成8
  103. if(show)
  104. {
  105. SetUISizeDotsPositionByMove(false);
  106. }
  107. else
  108. {
  109. this._Owner.Parent.SuspendLayout();
  110. for(inti=0;i<DOT_COUNT;i++)
  111. {
  112. this._UISizeDot[i].Visible=show;
  113. }
  114. this._Owner.Parent.ResumeLayout();
  115. return;
  116. }
  117. if(this._UISizeMode==ENUM_UISizeMode.FixNone)
  118. {
  119. for(inti=0;i<DOT_COUNT;i++)
  120. {
  121. this._UISizeDot[i].BorderColor=this._DotBorderColor;
  122. this._UISizeDot[i].BackColor=this._DotColor;
  123. this._UISizeDot[i].Visible=show;
  124. }
  125. }
  126. elseif(this._UISizeMode==ENUM_UISizeMode.FixLocation)
  127. {
  128. for(inti=0;i<DOT_COUNT;i++)
  129. {
  130. this._UISizeDot[i].BorderColor=this._DotBorderColor;
  131. this._UISizeDot[i].BackColor=this._DotColor;
  132. this._UISizeDot[i].Visible=show;
  133. }
  134. this._UISizeDot[0].BackColor=System.Drawing.Color.FromArgb(9,55,119);
  135. this._UISizeDot[0].Movable=false;
  136. this._UISizeDot[1].BackColor=System.Drawing.Color.FromArgb(9,55,119);
  137. this._UISizeDot[1].Movable=false;
  138. this._UISizeDot[2].BackColor=System.Drawing.Color.FromArgb(9,55,119);
  139. this._UISizeDot[2].Movable=false;
  140. this._UISizeDot[6].BackColor=System.Drawing.Color.FromArgb(9,55,119);
  141. this._UISizeDot[6].Movable=false;
  142. this._UISizeDot[7].BackColor=System.Drawing.Color.FromArgb(9,55,119);
  143. this._UISizeDot[7].Movable=false;
  144. }
  145. elseif(this._UISizeMode==ENUM_UISizeMode.FixHeight)
  146. {
  147. this._UISizeDot[0].Visible=false;
  148. this._UISizeDot[1].Visible=false;
  149. this._UISizeDot[2].Visible=false;
  150. this._UISizeDot[3].BorderColor=this._DotBorderColor;
  151. this._UISizeDot[3].BackColor=this._DotColor;
  152. this._UISizeDot[3].Refresh();
  153. this._UISizeDot[3].Visible=show;
  154. this._UISizeDot[4].Visible=false;
  155. this._UISizeDot[5].Visible=false;
  156. this._UISizeDot[6].Visible=false;
  157. this._UISizeDot[7].BorderColor=this._DotBorderColor;
  158. this._UISizeDot[7].BackColor=this._DotColor;
  159. this._UISizeDot[7].Refresh();
  160. this._UISizeDot[7].Visible=show;
  161. }
  162. elseif(this._UISizeMode==ENUM_UISizeMode.FixWidth)
  163. {
  164. this._UISizeDot[0].Visible=false;
  165. this._UISizeDot[1].BorderColor=this._DotBorderColor;
  166. this._UISizeDot[1].BackColor=this._DotColor;
  167. this._UISizeDot[1].Visible=show;
  168. this._UISizeDot[1].Refresh();
  169. this._UISizeDot[2].Visible=false;
  170. this._UISizeDot[3].Visible=false;
  171. this._UISizeDot[4].Visible=false;
  172. this._UISizeDot[5].BorderColor=this._DotBorderColor;
  173. this._UISizeDot[5].BackColor=this._DotColor;
  174. this._UISizeDot[5].Visible=show;
  175. this._UISizeDot[5].Refresh();
  176. this._UISizeDot[6].Visible=false;
  177. this._UISizeDot[7].Visible=false;
  178. }
  179. elseif(this._UISizeMode==ENUM_UISizeMode.FixBoth)
  180. {
  181. for(inti=0;i<DOT_COUNT;i++)
  182. {
  183. this._UISizeDot[i].BorderColor=this._DotBorderColor;
  184. this._UISizeDot[i].BackColor=System.Drawing.Color.FromArgb(9,55,119);
  185. this._UISizeDot[i].Movable=false;
  186. this._UISizeDot[i].Visible=show;
  187. }
  188. }
  189. }
  190. privatevoidSetUISizeDotsPosition()
  191. {
  192. intleft,width,height,top;
  193. left=this._Owner.Left;
  194. top=this._Owner.Top;
  195. width=this._Owner.Width;
  196. height=this._Owner.Height;
  197. this._UISizeDot[0].Location=newPoint(left-DOT_WIDTH-DOT_SPACE,top-DOT_HEIGHT-DOT_SPACE);
  198. this._UISizeDot[1].Location=newPoint(left+width/2-DOT_WIDTH/2,top-DOT_HEIGHT-DOT_SPACE);
  199. this._UISizeDot[2].Location=newPoint(left+width+DOT_SPACE,top-DOT_HEIGHT-DOT_SPACE);
  200. this._UISizeDot[3].Location=newPoint(left+width+DOT_SPACE,top+height/2-DOT_HEIGHT/2);
  201. this._UISizeDot[4].Location=newPoint(left+width+DOT_SPACE,top+height+DOT_SPACE);
  202. this._UISizeDot[5].Location=newPoint(left+width/2-DOT_WIDTH/2,top+height+DOT_SPACE);
  203. this._UISizeDot[6].Location=newPoint(left-DOT_WIDTH-DOT_SPACE,top+height+DOT_SPACE);
  204. this._UISizeDot[7].Location=newPoint(left-DOT_WIDTH-DOT_SPACE,top+height/2-DOT_HEIGHT/2);
  205. }
  206. privatevoidSetUISizeDotsPositionByMove(boolShow)
  207. {
  208. intleft,width,height,top;
  209. left=this._Owner.Left;
  210. top=this._Owner.Top;
  211. width=this._Owner.Width;
  212. height=this._Owner.Height;
  213. this._UISizeDot[0].Visible=Show;
  214. this._UISizeDot[1].Visible=Show;
  215. this._UISizeDot[2].Visible=Show;
  216. this._UISizeDot[3].Visible=Show;
  217. this._UISizeDot[4].Visible=Show;
  218. this._UISizeDot[5].Visible=Show;
  219. this._UISizeDot[6].Visible=Show;
  220. this._UISizeDot[7].Visible=Show;
  221. this._UISizeDot[0].BringToFront();
  222. this._UISizeDot[1].BringToFront();
  223. this._UISizeDot[2].BringToFront();
  224. this._UISizeDot[3].BringToFront();
  225. this._UISizeDot[4].BringToFront();
  226. this._UISizeDot[5].BringToFront();
  227. this._UISizeDot[6].BringToFront();
  228. this._UISizeDot[7].BringToFront();
  229. this._UISizeDot[0].Location=newPoint(left-DOT_WIDTH-DOT_SPACE,top-DOT_HEIGHT-DOT_SPACE);
  230. this._UISizeDot[1].Location=newPoint(left+width/2-DOT_WIDTH/2,top-DOT_HEIGHT-DOT_SPACE);
  231. this._UISizeDot[2].Location=newPoint(left+width+DOT_SPACE,top-DOT_HEIGHT-DOT_SPACE);
  232. this._UISizeDot[3].Location=newPoint(left+width+DOT_SPACE,top+height/2-DOT_HEIGHT/2);
  233. this._UISizeDot[4].Location=newPoint(left+width+DOT_SPACE,top+height+DOT_SPACE);
  234. this._UISizeDot[5].Location=newPoint(left+width/2-DOT_WIDTH/2,top+height+DOT_SPACE);
  235. this._UISizeDot[6].Location=newPoint(left-DOT_WIDTH-DOT_SPACE,top+height+DOT_SPACE);
  236. this._UISizeDot[7].Location=newPoint(left-DOT_WIDTH-DOT_SPACE,top+height/2-DOT_HEIGHT/2);
  237. }
  238. privatevoidUISizeDot_MouseDown(objectsender,System.Windows.Forms.MouseEventArgse)
  239. {
  240. if(!((UISizeDot)sender).Movable)
  241. {
  242. return;
  243. }
  244. j++;
  245. this.ShowUISizeDots(false);
  246. this._BeginDrag=true;
  247. this._ClickAtX=e.X;
  248. this._ClickAtY=e.Y;
  249. this._OldTop=this._Owner.Top;
  250. this._OldLeft=this._Owner.Left;
  251. this._NewTop=this._Owner.Top;
  252. this._NewLeft=this._Owner.Left;
  253. this._OldHeight=this._Owner.Height;
  254. this._OldWidth=this._Owner.Width;
  255. Rectanglerect=newRectangle(this._NewLeft-1,this._NewTop-1,this._OldWidth+2,this._OldHeight+2);
  256. //this._Owner.Parent.CreateGraphics().DrawRectangle(newPen(Color.Black,2),rect);
  257. this._OldRect=rect;
  258. if(this.MouseDown!=null)
  259. this.MouseDown(sender,e);
  260. }
  261. privatevoidUISizeDot_MouseMove(objectsender,System.Windows.Forms.MouseEventArgse)
  262. {
  263. if(!((UISizeDot)sender).Movable)
  264. {
  265. return;
  266. }
  267. if(this._BeginDrag)
  268. {
  269. inteX=e.X-this._ClickAtX;
  270. inteY=e.Y-this._ClickAtY;
  271. if(this._UISizeDot[0]==sender)
  272. {
  273. this._Owner.Location=newSystem.Drawing.Point(this._NewLeft+eX,this._NewTop+eY);
  274. this._Owner.Size=newSystem.Drawing.Size(this._Owner.Width-eX,this._Owner.Height-eY);
  275. }
  276. elseif(this._UISizeDot[1]==sender)
  277. {
  278. this._Owner.Location=newSystem.Drawing.Point(this._NewLeft,this._NewTop+eY);
  279. this._Owner.Size=newSystem.Drawing.Size(this._Owner.Width,this._Owner.Height-eY);
  280. }
  281. elseif(this._UISizeDot[2]==sender)
  282. {
  283. this._Owner.Location=newSystem.Drawing.Point(this._NewLeft,this._NewTop+eY);
  284. this._Owner.Size=newSystem.Drawing.Size(this._Owner.Width+eX,this._Owner.Height-eY);
  285. }
  286. elseif(this._UISizeDot[3]==sender)
  287. {
  288. this._Owner.Size=newSystem.Drawing.Size(this._Owner.Width+eX,this._Owner.Height);
  289. }
  290. elseif(this._UISizeDot[4]==sender)
  291. {
  292. this._Owner.Size=newSystem.Drawing.Size(this._Owner.Width+eX,this._Owner.Height+eY);
  293. }
  294. elseif(this._UISizeDot[5]==sender)
  295. {
  296. this._Owner.Size=newSystem.Drawing.Size(this._Owner.Width,this._Owner.Height+eY);
  297. }
  298. elseif(this._UISizeDot[6]==sender)
  299. {
  300. this._Owner.Location=newSystem.Drawing.Point(this._NewLeft+eX,this._NewTop);
  301. this._Owner.Size=newSystem.Drawing.Size(this._Owner.Size.Width-eX,this._Owner.Height+eY);
  302. }
  303. elseif(this._UISizeDot[7]==sender)
  304. {
  305. this._Owner.Location=newSystem.Drawing.Point(this._NewLeft+eX,this._NewTop);
  306. this._Owner.Size=newSystem.Drawing.Size(_Owner.Width-eX,this._Owner.Height);
  307. }
  308. this._NewTop=this._Owner.Top;
  309. this._NewLeft=this._Owner.Left;
  310. //this._OldHeight=this._Owner.Height;
  311. //this._OldWidth=this._Owner.Width;
  312. SetUISizeDotsPosition();
  313. this._Owner.Refresh();
  314. this._Owner.Parent.Refresh();
  315. //this._Owner.Parent.CreateGraphics().DrawRectangle(newPen(this._Owner.BackColor,2),this._OldRect);
  316. Rectanglerect=newRectangle(this._NewLeft-1,this._NewTop-1,this._Owner.Width+2,this._Owner.Height+2);
  317. //this._Owner.Parent.CreateGraphics().DrawRectangle(newPen(Color.Black,2),rect);
  318. this._OldRect=rect;
  319. }
  320. if(this.MouseMove!=null)
  321. this.MouseMove(sender,e);
  322. }
  323. privatevoidUISizeDot_MouseUp(objectsender,System.Windows.Forms.MouseEventArgse)
  324. {
  325. if(!((UISizeDot)sender).Movable)
  326. {
  327. return;
  328. }
  329. HashtableOldWidth;
  330. HashtableOldHeight;
  331. HashtableNewWidth;
  332. HashtableNewHeight;
  333. //Test.UIResizeCommandResizeCommand;
  334. //this._Owner.Parent.CreateGraphics().DrawRectangle(newPen(this._Owner.BackColor,2),this._OldRect);
  335. this.ShowUISizeDots(true);
  336. //使用UIResizeCommand,这里主要是保存现场,这样可以方便实现Undo和Redo
  337. if(this._OldHeight!=this._Owner.Height||this._OldWidth!=this._Owner.Width)
  338. {
  339. OldWidth=newHashtable();
  340. OldHeight=newHashtable();
  341. NewWidth=newHashtable();
  342. NewHeight=newHashtable();
  343. OldWidth.Add(this._Owner,this._OldWidth);
  344. OldHeight.Add(this._Owner,this._OldHeight);
  345. NewWidth.Add(this._Owner,this._Owner.Width);
  346. NewHeight.Add(this._Owner,this._Owner.Height);
  347. }
  348. this._BeginDrag=false;
  349. if(this.MouseUp!=null)
  350. this.MouseUp(sender,e);
  351. }
  352. }

3、设计器上控件与调整手柄的对应方法:

在我们的UISizeKnob中,有一个函数ShowUISizeDots(bool show)。这里的show参数就是表示,显示或者隐藏控件的调整手柄。

所以为了方便,我在前面的Form中增加这样的变量和函数:

变量private Hashtable _HashUISizeKnob负责缓存每个新增加的控件对应的UISizeKnob对象,因为一个Control只能对应一个UISizeKnob对象。

另外,我们怎么知道新增了控件呢,这里需要实现事件Control.ControlAdded,在这里是实现FormControlAdded事件。

Form的代码修改后如下:

  1. //在Form中增加几个Button,分别命名为cmdArrow,cmdLabel,cmdTextBox,cmdComboBox,cmdGroupBox
  2. publicpartialclassForm1:Form
  3. {
  4. privateMouseHook_MouseHook;
  5. //我们将所有的已经与具体控件关联了的UISizeKnob缓存在这个HashTable中
  6. privateHashtable_HashUISizeKnob;
  7. publicForm1()
  8. {
  9. InitializeComponent();
  10. this._MouseHook=newMouseHook(this);
  11. this._HashUISizeKnob=newHashtable();
  12. //为了简洁明了,我们在ControlAdded中来设置具体控件和UISizeKnob的关联
  13. this.ControlAdded+=newControlEventHandler(Form1_ControlAdded);
  14. }
  15. voidForm1_ControlAdded(objectsender,ControlEventArgse)
  16. {
  17. if(!(e.ControlisUISizeDot))
  18. {
  19. this._HashUISizeKnob.Add(e.Control,newUISizeKnob(e.Control));
  20. //点击控件的时候,显示控件的选择
  21. e.Control.Click+=newEventHandler(Control_Click);
  22. }
  23. }
  24. voidControl_Click(objectsender,EventArgse)
  25. {
  26. //寿险清除已经选择的控件
  27. foreach(UISizeKnobknobinthis._HashUISizeKnob.Values)
  28. {
  29. knob.ShowUISizeDots(false);
  30. }
  31. try
  32. {
  33. ((UISizeKnob)this._HashUISizeKnob[sender]).ShowUISizeDots(true);
  34. }
  35. catch{}
  36. }
  37. privatevoidcmdArrow_Click(objectsender,EventArgse)
  38. {
  39. SettingService.Instance.SelectedToolBoxControl=null;
  40. }
  41. privatevoidcmdLabel_Click(objectsender,EventArgse)
  42. {
  43. SettingService.Instance.SelectedToolBoxControl=newLabel();
  44. }
  45. privatevoidcmdTextBox_Click(objectsender,EventArgse)
  46. {
  47. SettingService.Instance.SelectedToolBoxControl=newTextBox();
  48. }
  49. privatevoidcmdComboBox_Click(objectsender,EventArgse)
  50. {
  51. SettingService.Instance.SelectedToolBoxControl=newComboBox();
  52. }
  53. privatevoidcmdGroupBox_Click(objectsender,EventArgse)
  54. {
  55. SettingService.Instance.SelectedToolBoxControl=newGroupBox();
  56. }
  57. }

以上就是实现控件选择的关键部分,各位结合上面一篇,应该是很容易理解的,代码都是可运行的,自己拷贝过去就可以了。

相关文章:

C#基础系列:开发自己的窗体设计器(总纲)

C#基础系列:开发自己的窗体设计器(在容器上拖动鼠标增加控件)

分享到:
评论

相关推荐

    c#窗体设计器实现.rar

    所以我就想能够弄一个类似于vs2005的WinForm窗体设计器的开发平台,让用户拖拖拽拽就可以添加自己需要的控件,或者删除不需要的控件,从而完成大部分的工作,实现功能的扩展,而我需要做的,只不过是写写插件代码。...

    【C#】窗体和控件综合设计(多文本编辑器)

    利用可视化编程思想,综合应用C#的MDI窗体设计方法,掌握各控件设计方法,MenuStrip、ContextMenuStrip、ToolStrip、StatusStrip等,以及文件管理操作等。 资源为可运行源码,仅供参考,如有问题,欢迎留言讨论!

    武汉理工大学C#实验4源代码_窗体和控件综合设计_多文档编辑器

    这是武汉理工大学计算机学院可视化编程(C#)课程的第四次实验:窗体和控件综合设计 的源代码。运行环境:VS2017。

    C#泛型类窗体继承设计器无法使用解决办法,解决案例Demo

    winform窗体继承泛型类时,设计器无法使用解决办法: 当我们使用winform程序时,winform窗体程序和控件程序都是可以通过设计器进行控件拖拽的,但如果我们继承了一个带有泛型的form基类.那么设计器是无法使用的.

    C#制作的Winform窗体设计器(仿VS界面)

    Winform窗体设计器,基于C#源码实现,界面仿VisualStudio,这个窗体设计器可显示出制作窗体上一些必备元素的属性信息源码也是可以编译的。没有使用微软Runtime FormDesigner技术

    WinForm运行时模仿窗体设计调整控件大小和位置

    WinForm运行时模仿窗体设计调整控件大小和位置 具体讲解看https://blog.csdn.net/weixin_38211198/article/details/90639601

    C#工具箱自己开发

    自己开发的C#工具箱,包含各种常用仪表控件,曲线图控件,水塔,开关,按钮控件。尽情相互交流留下宝贵意见

    武汉理工大学可视化编程_实验:C#窗体和控件综合设计_多文档编辑器

    这是武汉理工大学计算机学院可视化编程(C#)课程的第四次实验:窗体和控件综合设计(多文档编辑器)的源代码。压缩包内含运行源代码和两份参考资料。运行环境:VS2017。

    C#开发实例大全(基础卷).软件开发技术联盟(带详细书签) PDF 下载

    主要内容有C#开发环境的使用、C#语言基础应用、字符串处理技术、数组和集合的使用、面向对象编程技术、数据结构与算法、Windows窗体基础、特色窗体界面、窗体控制技术、MDI窗体和继承窗体、Windows常用控件的使用、...

    C# 控件大全

    学习窗体控件的编程。首先介绍如何使用窗体设计器向窗体中添加控件以及如何在窗体设计器中调整控件位置和大小等属性。然后依次介绍各个常用的控件,包括控件所特有的属性和事件。

    C#控件大全.ppt

    学习窗体控件的编程。首先介绍如何使用窗体设计器向窗体中添加控件以及如何在窗体设计器中调整控件位置和大小等属性。然后依次介绍各个常用的控件,

    明日科技C#开发入门及项目实战

    实例093 利用选择控件实现权限设置 实例094 利用richtextbox控件显示图文数据 实例095 在listbox控件间交换数据 第10章 windows应用程序高级控件 实例096 使用imagelist组件制作动画图片 实例097 在combobox下拉...

    C#控件大全

    C#控件大全,首先介绍如何使用窗体设计器向窗体中添加控件以及如何在窗体设计器中调整控件位置和大小等属性。然后依次介绍各个常用的控件,包括控件所特有的属性和事件。

    Visual+C#+2008程序设计经典案例设计与实现.rar

    Visual+C#+2008程序设计经典案例设计与实现 第1章 Visual C#2008与窗体界面 案例1 飘动动画窗体 案例2 透明动画窗体 案例3 利用API函数实现动画窗体 案例4 闪烁动画窗体 案例5 滚动字幕动画窗体 案例6 超女卡通...

    C#控件大全控件的使用

    C#控件大全控件的使用 学习窗体控件的编程。首先介绍如何使用窗体设计器向窗体中添加控件以及如何在窗体设计器中调整控件位置和大小等属性。然后依次介绍各个常用的控件,包括控件所特有的属性和事件。

    C#控件简介

    首先介绍如何使用窗体设计器向窗体中添加控件以及如何在窗体设计器中调整控件位置和大小等属性。然后依次介绍各个常用的控件,包括控件所特有的属性和事件。 1 纲要 2 添加控件 3 调整控件 4 控件的分类介绍

    C#控件大全,提供C#控件的知识

    C#控件大全 分章节学习 学习窗体控件的编程。首先介绍如何使用窗体设计器向窗体中添加控件以及如何在窗体设计器中调整控件位置和大小等属性。然后依次介绍各个常用的控件,包括控件所特有的属性和事件。

    C#开发典型模块大全(光盘)第二部分

    明日科技出版的c#开发典型模块大全配套光盘,要的可以下载,因大小受限,分开上传! 第1章 认识C#及开发环境 1.1 C#概述 1.1.1 C#发展历程 1.1.2 C#语言编程环境 1.2.NETFramework2.0简介 1.2.1 什么是....

Global site tag (gtag.js) - Google Analytics