前提
入行已經(jīng)7,8年了,一直想做一套漂亮點(diǎn)的自定義控件,于是就有了本系列文章。
開(kāi)源地址:https://gitee.com/kwwwvagaa/net_winform_custom_control
<https://gitee.com/kwwwvagaa/net_winform_custom_control>
如果覺(jué)得寫(xiě)的還行,請(qǐng)點(diǎn)個(gè) star 支持一下吧
歡迎前來(lái)交流探討: 企鵝群568015492? <https://shang.qq.com/wpa/qunwpa?
idkey=6e08741ef16fe53bf0314c1c9e336c4f626047943a8b76bac062361bab6b4f8d>
目錄
https://www.cnblogs.com/bfyx/p/11364884.html
<https://www.cnblogs.com/bfyx/p/11364884.html>
準(zhǔn)備工作
其實(shí)就是1個(gè)橫向的線和縱向的線,沒(méi)有什么技術(shù)含量,至于為什么要等于呢,就是為了讓效果統(tǒng)一,用起來(lái)方便
開(kāi)始
橫向的分割線
添加用戶(hù)控件,命名UCSplitLine_H
全部代碼如下
1 // 版權(quán)所有 黃正輝 交流群:568015492 QQ:623128629 2 // 文件名稱(chēng):UCSplitLine_H.cs 3 //
創(chuàng)建日期:2019-08-15 16:03:21 4 // 功能描述:Split 5 // 項(xiàng)目地址:
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
public partial class UCSplitLine_H : UserControl 18 { 19 public UCSplitLine_H()
20 { 21 InitializeComponent(); 22 this.TabStop = false; 23 } 24 } 25 } View
Code 1 namespace HZH_Controls.Controls 2 { 3 partial class UCSplitLine_H 4
{ 5 /// <summary> 6 /// 必需的設(shè)計(jì)器變量。 7 /// </summary> 8 private
System.ComponentModel.IContainer components =null; 9 10 /// <summary> 11 ///
清理所有正在使用的資源。12 /// </summary> 13 /// <param name="disposing">如果應(yīng)釋放托管資源,為
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 組件設(shè)計(jì)器生成的代碼 24 25 /// <summary>
26 /// 設(shè)計(jì)器支持所需的方法 - 不要 27 /// 使用代碼編輯器修改此方法的內(nèi)容。 28 /// </summary> 29 private void
InitializeComponent()30 { 31 this.SuspendLayout(); 32 // 33 // UCSplitLine_H
34 // 35 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None; 36 this
.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(232)))), ((int)(((byte
)(232)))), ((int)(((byte)(232))))); 37 this.Name = "UCSplitLine_H"; 38 this
.Size =new System.Drawing.Size(100, 1); 39 this.ResumeLayout(false); 40 41 } 42
43 #endregion 44 } 45 } View Code
?
縱向的分割線
添加用戶(hù)控件,命名UCSplitLine_V
全部代碼如下
1 // 版權(quán)所有 黃正輝 交流群:568015492 QQ:623128629 2 // 文件名稱(chēng):UCSplitLine_V.cs 3 //
創(chuàng)建日期:2019-08-15 16:03:25 4 // 功能描述:Split 5 // 項(xiàng)目地址:
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
public partial class UCSplitLine_V : UserControl 18 { 19 public UCSplitLine_V()
20 { 21 InitializeComponent(); 22 this.TabStop = false; 23 } 24 } 25 } View
Code 1 namespace HZH_Controls.Controls 2 { 3 partial class UCSplitLine_V 4
{ 5 /// <summary> 6 /// 必需的設(shè)計(jì)器變量。 7 /// </summary> 8 private
System.ComponentModel.IContainer components =null; 9 10 /// <summary> 11 ///
清理所有正在使用的資源。12 /// </summary> 13 /// <param name="disposing">如果應(yīng)釋放托管資源,為
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 組件設(shè)計(jì)器生成的代碼 24 25 /// <summary>
26 /// 設(shè)計(jì)器支持所需的方法 - 不要 27 /// 使用代碼編輯器修改此方法的內(nèi)容。 28 /// </summary> 29 private void
InitializeComponent()30 { 31 this.SuspendLayout(); 32 // 33 // UCSplitLine_V
34 // 35 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None; 36 this
.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(232)))), ((int)(((byte
)(232)))), ((int)(((byte)(232))))); 37 this.Name = "UCSplitLine_V"; 38 this
.Size =new System.Drawing.Size(1, 100); 39 this.ResumeLayout(false); 40 41 } 42
43 #endregion 44 } 45 } View Code
用處及效果
用處:區(qū)域分隔時(shí)使用
效果:
最后的話
如果你喜歡的話,請(qǐng)到?https://gitee.com/kwwwvagaa/net_winform_custom_control
<https://gitee.com/kwwwvagaa/net_winform_custom_control>?點(diǎn)個(gè)星 星吧
熱門(mén)工具 換一換
