官网

http://www.hzhcontrols.com

前提

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

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

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

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

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

idkey=6e08741ef16fe53bf0314c1c9e336c4f626047943a8b76bac062361bab6b4f8d">

目录

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

准备工作

其实我也不知道这个应该叫什么名字,暂且叫有后退的窗体吧,这个窗体继承子基类窗体FrmBase,如果你对FrmBase还不了解,请移步 (十七)c#Winform自定义控件-基类窗体 查看

开始

添加一个Form,命名FrmBack,继承自FrmBase

属性

  private string _frmTitle = "自定义窗体";
/// <summary>
/// 窗体标题
/// </summary>
[Description("窗体标题"), Category("自定义")]
public string FrmTitle
{
get { return _frmTitle; }
set
{
_frmTitle = value;
btnBack1.BtnText = value;
}
}
[Description("帮助按钮点击事件"), Category("自定义")]
public event EventHandler BtnHelpClick;

一点小事件

  private void btnBack1_btnClick(object sender, EventArgs e)
{
this.Close();
} private void label1_MouseDown(object sender, MouseEventArgs e)
{
if (BtnHelpClick != null)
BtnHelpClick(sender, e);
}

完整代码

 // 版权所有  黄正辉  交流群:568015492   QQ:623128629
// 文件名称:FrmTemp1.cs
// 创建日期:2019-08-15 16:04:48
// 功能描述:FrmTemp1
// 项目地址:https://gitee.com/kwwwvagaa/net_winform_custom_control
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms; namespace HZH_Controls.Forms
{
[Designer("System.Windows.Forms.Design.ParentControlDesigner, System.Design", typeof(System.ComponentModel.Design.IDesigner))]
public partial class FrmBack : FrmBase
{
private string _frmTitle = "自定义窗体";
/// <summary>
/// 窗体标题
/// </summary>
[Description("窗体标题"), Category("自定义")]
public string FrmTitle
{
get { return _frmTitle; }
set
{
_frmTitle = value;
btnBack1.BtnText = value;
}
}
[Description("帮助按钮点击事件"), Category("自定义")]
public event EventHandler BtnHelpClick; public FrmBack()
{
InitializeComponent();
} private void btnBack1_btnClick(object sender, EventArgs e)
{
this.Close();
} private void label1_MouseDown(object sender, MouseEventArgs e)
{
if (BtnHelpClick != null)
BtnHelpClick(sender, e);
}
}
}
 namespace HZH_Controls.Forms
{
partial class FrmBack
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null; /// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
} #region Windows Form Designer generated code /// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FrmBack));
this.panTop = new System.Windows.Forms.Panel();
this.label1 = new System.Windows.Forms.Label();
this.btnBack1 = new HZH_Controls.Controls.UCBtnImg();
this.imageList1 = new System.Windows.Forms.ImageList(this.components);
this.ucSplitLine_H1 = new HZH_Controls.Controls.UCSplitLine_H();
this.panTop.SuspendLayout();
this.SuspendLayout();
//
// panTop
//
this.panTop.Controls.Add(this.label1);
this.panTop.Controls.Add(this.btnBack1);
this.panTop.Dock = System.Windows.Forms.DockStyle.Top;
this.panTop.Location = new System.Drawing.Point(, );
this.panTop.Name = "panTop";
this.panTop.Size = new System.Drawing.Size(, );
this.panTop.TabIndex = ;
//
// label1
//
this.label1.BackColor = System.Drawing.Color.Transparent;
this.label1.Dock = System.Windows.Forms.DockStyle.Right;
this.label1.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Bold);
this.label1.Image = global::HZH_Controls.Properties.Resources.help;
this.label1.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
this.label1.Location = new System.Drawing.Point(, );
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(, );
this.label1.TabIndex = ;
this.label1.Text = "帮助";
this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
this.label1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.label1_MouseDown);
//
// btnBack1
//
this.btnBack1.BackColor = System.Drawing.Color.Transparent;
this.btnBack1.BtnBackColor = System.Drawing.Color.Transparent;
this.btnBack1.BtnFont = new System.Drawing.Font("微软雅黑", 17F);
this.btnBack1.BtnForeColor = System.Drawing.Color.FromArgb(((int)(((byte)()))), ((int)(((byte)()))), ((int)(((byte)()))));
this.btnBack1.BtnText = "自定义按钮";
this.btnBack1.ConerRadius = ;
this.btnBack1.Cursor = System.Windows.Forms.Cursors.Hand;
this.btnBack1.Dock = System.Windows.Forms.DockStyle.Left;
this.btnBack1.FillColor = System.Drawing.Color.FromArgb(((int)(((byte)()))), ((int)(((byte)()))), ((int)(((byte)()))));
this.btnBack1.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel);
this.btnBack1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)()))), ((int)(((byte)()))), ((int)(((byte)()))));
this.btnBack1.Image = ((System.Drawing.Image)(resources.GetObject("btnBack1.Image")));
this.btnBack1.IsRadius = true;
this.btnBack1.IsShowRect = true;
this.btnBack1.IsShowTips = false;
this.btnBack1.Location = new System.Drawing.Point(, );
this.btnBack1.Margin = new System.Windows.Forms.Padding(, , , );
this.btnBack1.Name = "btnBack1";
this.btnBack1.RectColor = System.Drawing.Color.FromArgb(((int)(((byte)()))), ((int)(((byte)()))), ((int)(((byte)()))));
this.btnBack1.RectWidth = ;
this.btnBack1.Size = new System.Drawing.Size(, );
this.btnBack1.TabIndex = ;
this.btnBack1.TabStop = false;
this.btnBack1.TipsText = "";
this.btnBack1.BtnClick += new System.EventHandler(this.btnBack1_btnClick);
//
// imageList1
//
this.imageList1.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList1.ImageStream")));
this.imageList1.TransparentColor = System.Drawing.Color.Transparent;
this.imageList1.Images.SetKeyName(, "help.png");
//
// ucSplitLine_H1
//
this.ucSplitLine_H1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)()))), ((int)(((byte)()))), ((int)(((byte)()))));
this.ucSplitLine_H1.Dock = System.Windows.Forms.DockStyle.Top;
this.ucSplitLine_H1.Location = new System.Drawing.Point(, );
this.ucSplitLine_H1.MaximumSize = new System.Drawing.Size(, );
this.ucSplitLine_H1.Name = "ucSplitLine_H1";
this.ucSplitLine_H1.Size = new System.Drawing.Size(, );
this.ucSplitLine_H1.TabIndex = ;
this.ucSplitLine_H1.TabStop = false;
//
// FrmTemp1
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)()))), ((int)(((byte)()))), ((int)(((byte)()))));
this.ClientSize = new System.Drawing.Size(, );
this.Controls.Add(this.ucSplitLine_H1);
this.Controls.Add(this.panTop);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Name = "FrmTemp1";
this.ShowIcon = false;
this.ShowInTaskbar = false;
this.Text = "FrmTemp1";
this.panTop.ResumeLayout(false);
this.ResumeLayout(false); } #endregion private Controls.UCBtnImg btnBack1;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.ImageList imageList1;
private Controls.UCSplitLine_H ucSplitLine_H1;
private System.Windows.Forms.Panel panTop;
}
}

设计效果

用处及效果

用处:这个看个人使用情况吧,你高兴的话就用这个窗体就可以了

最后的话

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

(二十)c#Winform自定义控件-有后退的窗体的更多相关文章

  1. (三十二)c#Winform自定义控件-表格

    前提 入行已经7,8年了,一直想做一套漂亮点的自定义控件,于是就有了本系列文章. 开源地址:https://gitee.com/kwwwvagaa/net_winform_custom_control ...

  2. (八十二)c#Winform自定义控件-穿梭框

    前提 入行已经7,8年了,一直想做一套漂亮点的自定义控件,于是就有了本系列文章. GitHub:https://github.com/kwwwvagaa/NetWinformControl 码云:ht ...

  3. (二十二)c#Winform自定义控件-半透明窗体

    前提 入行已经7,8年了,一直想做一套漂亮点的自定义控件,于是就有了本系列文章. 开源地址:https://gitee.com/kwwwvagaa/net_winform_custom_control ...

  4. (四十二)c#Winform自定义控件-进度条扩展

    前提 入行已经7,8年了,一直想做一套漂亮点的自定义控件,于是就有了本系列文章. GitHub:https://github.com/kwwwvagaa/NetWinformControl 码云:ht ...

  5. (二)c#Winform自定义控件-按钮

    前提 入行已经7,8年了,一直想做一套漂亮点的自定义控件,于是就有了本系列文章. 开源地址:https://gitee.com/kwwwvagaa/net_winform_custom_control ...

  6. (七十三)c#Winform自定义控件-资源加载窗体

    前提 入行已经7,8年了,一直想做一套漂亮点的自定义控件,于是就有了本系列文章. GitHub:https://github.com/kwwwvagaa/NetWinformControl 码云:ht ...

  7. (十二)c#Winform自定义控件-分页控件

    前提 入行已经7,8年了,一直想做一套漂亮点的自定义控件,于是就有了本系列文章. 开源地址:https://gitee.com/kwwwvagaa/net_winform_custom_control ...

  8. (五十二)c#Winform自定义控件-LED数字

    前提 入行已经7,8年了,一直想做一套漂亮点的自定义控件,于是就有了本系列文章. GitHub:https://github.com/kwwwvagaa/NetWinformControl 码云:ht ...

  9. (六十二)c#Winform自定义控件-警灯(工业)

    前提 入行已经7,8年了,一直想做一套漂亮点的自定义控件,于是就有了本系列文章. GitHub:https://github.com/kwwwvagaa/NetWinformControl 码云:ht ...

随机推荐

  1. FTP工具便携版 FileZilla 3.38.0

    FileZilla 客户端是一个快速可靠的.跨平台的FTP,FTPS和SFTP客户端.具有图形用户界面(GUI)和很多有用的特性.由NoCmd提供的 FileZilla Client 中文便携版,具有 ...

  2. ES6中的解构

    数组中的解构: 输出 : 白板 幺鸡 二条 对象的解构: 输出: 老王 12 数组的结构用[];对象的解构用{}:一定要区分它是数组还是解构. 区分方法:看 它是在赋值还是在拿值,等号左边,都为解构, ...

  3. 数据库系统概念:基础的SQL

    public class DataBase { public static void main() { } } /* 3.1 SQL查询语言概览 SQL语言有一下几个部分: 数据定义语言:提供定义关系 ...

  4. python+selenium 批量执行时出现随机报错问题【已解决】

    出现场景:用discover方法批量执行py文件,出现随机性的报错(有时a.py报错,有时b.py报错...),共同特点:均是打开新窗口后,切换最新窗口,但定位不到新窗口的元素,超时报错.由于个人项目 ...

  5. [leetcode] 8. String to Integer (atoi) (Medium)

    实现字符串转整形数字 遵循几个规则: 1. 函数首先丢弃尽可能多的空格字符,直到找到第一个非空格字符. 2. 此时取初始加号或减号. 3. 后面跟着尽可能多的数字,并将它们解释为一个数值. 4. 字符 ...

  6. ArcGIS API For JavaScript 开发(三)使用小部件设计页面框架

    其实上一个的鹰眼.比例尺.图例等都是小部件:这篇文章主要是页面布局设计,dojo提供了非常多的小部件,从功能的角度可以分为3大类:表单小部件.布局小部件和应用小部件. 表单小部件于HTML中的表单部件 ...

  7. HTML --- <a href=”#”>与 <a href=”javascript:void(0)” 的区别

    <a href=”#”>中的“#”其实是锚点的意思,默认为#top,所以当页面比较长的时候,使用这种方式会让页面刷新到页首(页面的最上部) javascript:void(0)其实是一个死 ...

  8. Java集合系列(一):集合的定义及分类

    1. 集合的定义 什么是集合呢? 定义:集合是一个存放对象的引用的容器. 在Java中,集合位于java.util包下. 2. 集合和数组的区别(面试常问) 提到容器,就会想起数组,那么集合和数组的区 ...

  9. SQL SERVER中生僻字问题存储与查询问题

    以下仅记录碰到的几个问题 1.首先字段设置为varchar的时候存储后无法进行正常的显示 显示为? 此状态下匹配查询或者Like模糊查询都没问题 2.将字段设置为nvarchar,在进行插入或者跟新时 ...

  10. z-index不起作用

    摘录自 https://blog.csdn.net/apple_01150525/article/details/76546367 z-index无效的情况,一共有三种:1.父标签 position属 ...