<ul id="qxxfc"><fieldset id="qxxfc"><tr id="qxxfc"></tr></fieldset></ul>


      前提

      入行已經(jīng)7,8年了,一直想做一套漂亮點的自定義控件,于是就有了本系列文章。

      開源地址:https://gitee.com/kwwwvagaa/net_winform_custom_control
      <https://gitee.com/kwwwvagaa/net_winform_custom_control>

      如果覺得寫的還行,請點個 star 支持一下吧

      歡迎前來交流探討: 企鵝群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>

      準備工作

      其實我也不知道這個應(yīng)該叫什么名字,暫且叫有后退的窗體吧,這個窗體繼承子基類窗體FrmBase,如果你對FrmBase還不了解,請移步?
      (十七)c#Winform自定義控件-基類窗體 <https://www.cnblogs.com/bfyx/p/11363673.html>?查看

      開始

      添加一個Form,命名FrmBack,繼承自FrmBase

      屬性
      1 private string _frmTitle = "自定義窗體"; 2 /// <summary> 3 /// 窗體標題 4 ///
      </summary> 5 [Description("窗體標題"), Category("自定義")] 6 public string FrmTitle
      7 { 8 get { return _frmTitle; } 9 set 10 { 11 _frmTitle = value; 12
      btnBack1.BtnText = value; 13 } 14 } 15 [Description("幫助按鈕點擊事件"), Category("自定義
      ")] 16 public event EventHandler BtnHelpClick;
      一點小事件
      1 private void btnBack1_btnClick(object sender, EventArgs e) 2 { 3 this
      .Close(); 4 } 5 6 private void label1_MouseDown(object sender,
      MouseEventArgs e) 7 { 8 if (BtnHelpClick != null) 9 BtnHelpClick(sender, e);
      10 }
      完整代碼
      1 // 版權(quán)所有 黃正輝 交流群:568015492 QQ:623128629 2 // 文件名稱:FrmTemp1.cs 3 //
      創(chuàng)建日期:2019-08-15 16:04:48 4 // 功能描述:FrmTemp1 5 // 項目地址:
      https://gitee.com/kwwwvagaa/net_winform_custom_control 6 using System; 7 using
      System.Collections.Generic; 8 using System.ComponentModel; 9 using
      System.Data;10 using System.Drawing; 11 using System.Linq; 12 using System.Text;
      13 using System.Windows.Forms; 14 15 namespace HZH_Controls.Forms 16 { 17
      [Designer("System.Windows.Forms.Design.ParentControlDesigner, System.Design",
      typeof(System.ComponentModel.Design.IDesigner))] 18 public partial class
      FrmBack : FrmBase19 { 20 private string _frmTitle = "自定義窗體"; 21 /// <summary>
      22 /// 窗體標題 23 /// </summary> 24 [Description("窗體標題"), Category("自定義")] 25
      public string FrmTitle 26 { 27 get { return _frmTitle; } 28 set 29 { 30
      _frmTitle = value; 31 btnBack1.BtnText = value; 32 } 33 } 34 [Description("
      幫助按鈕點擊事件"), Category("自定義")] 35 public event EventHandler BtnHelpClick; 36 37
      public FrmBack() 38 { 39 InitializeComponent(); 40 } 41 42 private void
      btnBack1_btnClick(object sender, EventArgs e) 43 { 44 this.Close(); 45 } 46 47
      private void label1_MouseDown(object sender, MouseEventArgs e) 48 { 49 if
      (BtnHelpClick !=null) 50 BtnHelpClick(sender, e); 51 } 52 } 53 } View Code 1
      namespace HZH_Controls.Forms 2 { 3 partial class FrmBack 4 { 5 ///
      <summary> 6 /// Required designer variable. 7 /// </summary> 8 private
      System.ComponentModel.IContainer components =null; 9 10 /// <summary> 11 ///
      Clean up any resources being used. 12 /// </summary> 13 /// <param
      name="disposing">true if managed resources should be disposed; otherwise, 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 Windows Form Designer generated
      code 24 25 /// <summary> 26 /// Required method for Designer support - do not
      modify 27 /// the contents of this method with the code editor. 28 ///
      </summary> 29 private void InitializeComponent() 30 { 31 this.components =
      new System.ComponentModel.Container(); 32
      System.ComponentModel.ComponentResourceManager resources =new
      System.ComponentModel.ComponentResourceManager(typeof(FrmBack)); 33 this
      .panTop =new System.Windows.Forms.Panel(); 34 this.label1 = new
      System.Windows.Forms.Label(); 35 this.btnBack1 = new
      HZH_Controls.Controls.UCBtnImg(); 36 this.imageList1 = new
      System.Windows.Forms.ImageList(this.components); 37 this.ucSplitLine_H1 = new
      HZH_Controls.Controls.UCSplitLine_H(); 38 this.panTop.SuspendLayout(); 39 this
      .SuspendLayout(); 40 // 41 // panTop 42 // 43 this.panTop.Controls.Add(this
      .label1); 44 this.panTop.Controls.Add(this.btnBack1); 45 this.panTop.Dock =
      System.Windows.Forms.DockStyle.Top; 46 this.panTop.Location = new
      System.Drawing.Point(0, 0); 47 this.panTop.Name = "panTop"; 48 this
      .panTop.Size =new System.Drawing.Size(679, 60); 49 this.panTop.TabIndex = 2;
      50 // 51 // label1 52 // 53 this.label1.BackColor =
      System.Drawing.Color.Transparent; 54 this.label1.Dock =
      System.Windows.Forms.DockStyle.Right; 55 this.label1.Font = new
      System.Drawing.Font("微軟雅黑", 12F, System.Drawing.FontStyle.Bold); 56 this
      .label1.Image =global::HZH_Controls.Properties.Resources.help; 57 this
      .label1.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft; 58 this
      .label1.Location =new System.Drawing.Point(612, 0); 59 this.label1.Name = "
      label1"; 60 this.label1.Size = new System.Drawing.Size(67, 60); 61 this
      .label1.TabIndex =1; 62 this.label1.Text = "幫助"; 63 this.label1.TextAlign =
      System.Drawing.ContentAlignment.MiddleRight; 64 this.label1.MouseDown += new
      System.Windows.Forms.MouseEventHandler(this.label1_MouseDown); 65 // 66 //
      btnBack1 67 // 68 this.btnBack1.BackColor = System.Drawing.Color.Transparent;
      69 this.btnBack1.BtnBackColor = System.Drawing.Color.Transparent; 70 this
      .btnBack1.BtnFont =new System.Drawing.Font("微軟雅黑", 17F); 71 this
      .btnBack1.BtnForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(102)))),
      ((int)(((byte)(102)))), ((int)(((byte)(102))))); 72 this.btnBack1.BtnText = "
      自定義按鈕"; 73 this.btnBack1.ConerRadius = 5; 74 this.btnBack1.Cursor =
      System.Windows.Forms.Cursors.Hand; 75 this.btnBack1.Dock =
      System.Windows.Forms.DockStyle.Left; 76 this.btnBack1.FillColor =
      System.Drawing.Color.FromArgb(((int)(((byte)(247)))), ((int)(((byte)(247)))), ((
      int)(((byte)(247))))); 77 this.btnBack1.Font = new System.Drawing.Font("微軟雅黑",
      15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel); 78
      this.btnBack1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(102)))),
      ((int)(((byte)(102)))), ((int)(((byte)(102))))); 79 this.btnBack1.Image =
      ((System.Drawing.Image)(resources.GetObject("btnBack1.Image"))); 80 this
      .btnBack1.IsRadius =true; 81 this.btnBack1.IsShowRect = true; 82 this
      .btnBack1.IsShowTips =false; 83 this.btnBack1.Location = new
      System.Drawing.Point(0, 0); 84 this.btnBack1.Margin = new
      System.Windows.Forms.Padding(3, 4, 3, 4); 85 this.btnBack1.Name = "btnBack1";
      86 this.btnBack1.RectColor = System.Drawing.Color.FromArgb(((int)(((byte)(247
      )))), ((int)(((byte)(247)))), ((int)(((byte)(247))))); 87 this
      .btnBack1.RectWidth =1; 88 this.btnBack1.Size = new System.Drawing.Size(200, 60
      ); 89 this.btnBack1.TabIndex = 0; 90 this.btnBack1.TabStop = false; 91 this
      .btnBack1.TipsText =""; 92 this.btnBack1.BtnClick += new System.EventHandler(
      this.btnBack1_btnClick); 93 // 94 // imageList1 95 // 96 this
      .imageList1.ImageStream =
      ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("
      imageList1.ImageStream"))); 97 this.imageList1.TransparentColor =
      System.Drawing.Color.Transparent; 98 this.imageList1.Images.SetKeyName(0, "
      help.png"); 99 // 100 // ucSplitLine_H1 101 // 102 this
      .ucSplitLine_H1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(238
      )))), ((int)(((byte)(238)))), ((int)(((byte)(238))))); 103 this
      .ucSplitLine_H1.Dock = System.Windows.Forms.DockStyle.Top; 104 this
      .ucSplitLine_H1.Location =new System.Drawing.Point(0, 60); 105 this
      .ucSplitLine_H1.MaximumSize =new System.Drawing.Size(0, 1); 106 this
      .ucSplitLine_H1.Name ="ucSplitLine_H1"; 107 this.ucSplitLine_H1.Size = new
      System.Drawing.Size(679, 1); 108 this.ucSplitLine_H1.TabIndex = 0; 109 this
      .ucSplitLine_H1.TabStop =false; 110 // 111 // FrmTemp1 112 // 113 this
      .AutoScaleMode = System.Windows.Forms.AutoScaleMode.None; 114 this.BackColor =
      System.Drawing.Color.FromArgb(((int)(((byte)(247)))), ((int)(((byte)(247)))), ((
      int)(((byte)(247))))); 115 this.ClientSize = new System.Drawing.Size(679, 477);
      116 this.Controls.Add(this.ucSplitLine_H1); 117 this.Controls.Add(this.panTop);
      118 this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); 119
      this.Name = "FrmTemp1"; 120 this.ShowIcon = false; 121 this.ShowInTaskbar =
      false; 122 this.Text = "FrmTemp1"; 123 this.panTop.ResumeLayout(false); 124 this
      .ResumeLayout(false); 125 126 } 127 128 #endregion 129 130 private
      Controls.UCBtnImg btnBack1;131 private System.Windows.Forms.Label label1; 132
      private System.Windows.Forms.ImageList imageList1; 133 private
      Controls.UCSplitLine_H ucSplitLine_H1;134 private System.Windows.Forms.Panel
      panTop;135 } 136 } View Code
      設(shè)計效果



      用處及效果

      用處:這個看個人使用情況吧,你高興的話就用這個窗體就可以了

      最后的話

      如果你喜歡的話,請到?https://gitee.com/kwwwvagaa/net_winform_custom_control
      <https://gitee.com/kwwwvagaa/net_winform_custom_control>?點個星 星吧

      友情鏈接
      ioDraw流程圖
      API參考文檔
      OK工具箱
      云服務(wù)器優(yōu)惠
      阿里云優(yōu)惠券
      騰訊云優(yōu)惠券
      京東云優(yōu)惠券
      站點信息
      問題反饋
      郵箱:[email protected]
      QQ群:637538335
      關(guān)注微信

        <ul id="qxxfc"><fieldset id="qxxfc"><tr id="qxxfc"></tr></fieldset></ul>
          欧美成人精品欧美一 | 特级大胆西西4444www | A片在线免费观看 | 日本人又大又硬又粗bbbbb | 豆花视频入口在线播放 | 欧美xyx | 亚洲日韩成人 | 成人无码另类电影 | 在健身房里啪啪嗯受不了了 | 中文三区|