(八)c#Winform自定义控件-分割线-HZHControls

官网

https://www.hzhcontrols.cn

前提

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

GitHub:https://github.com/kwwwvagaa/NetWinformControl

码云:https://gitee.com/kwwwvagaa/net_winform_custom_control.git

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

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

目录

https://www.cnblogs.com/bfyx/p/11364884.html

准备工作

其实就是1个横向的线和纵向的线,没有什么技术含量,至于为什么要等于呢,就是为了让效果统一,用起来方便

开始

横向的分割线

添加用户控件,命名UCSplitLine_H

全部代码如下

复制代码
 1 // 版权所有  黄正辉  交流群:568015492   QQ:623128629
 2 // 文件名称:UCSplitLine_H.cs
 3 // 创建日期:2019-08-15 16:03:21
 4 // 功能描述:Split
 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     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         /// 必需的设计器变量。
 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.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
复制代码

 

纵向的分割线

添加用户控件,命名UCSplitLine_V

全部代码如下

复制代码
 1 // 版权所有  黄正辉  交流群:568015492   QQ:623128629
 2 // 文件名称:UCSplitLine_V.cs
 3 // 创建日期:2019-08-15 16:03:25
 4 // 功能描述:Split
 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     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         /// 必需的设计器变量。
 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.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
复制代码

用处及效果

用处:区域分隔时使用

效果:

最后的话

如果你喜欢的话,请到 https://gitee.com/kwwwvagaa/net_winform_custom_control 点个星 星吧

posted @   冰封一夏  阅读(5468)  评论(0编辑  收藏  举报
编辑推荐:
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
历史上的今天:
2016-08-16 一个人开发的html整站源码分享网站就这么上线了
HZHControls控件库官网:https://www.hzhcontrols.cn
点击右上角即可分享
微信分享提示