http://www.hzhcontrols.com

前提

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

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

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

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

欢迎前来交流探讨: 企鹅群568015492 (二十五)c#Winform自定义控件-有确定取消的窗体(一)-HZHControls

目录

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

准备工作

这个窗体继承子基类窗体FrmWithTitle,如果你对FrmWithTitle还不了解,请移步 (二十四)c#Winform自定义控件-单标题窗体 查看

开始

添加一个Form,命名FrmWithOKCancel1,继承FrmWithTitle

代码不多,直接上全部代码

 1 // 版权所有  黄正辉  交流群:568015492   QQ:623128629
 2 // 文件名称:FrmWithOKCancel1.cs
 3 // 创建日期:2019-08-15 16:05:16
 4 // 功能描述:FrmWithOKCancel1
 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 FrmWithOKCancel1 : FrmWithTitle
19     {
20         public FrmWithOKCancel1()
21         {
22             InitializeComponent();
23         }
24 
25         private void btnOK_BtnClick(object sender, EventArgs e)
26         {
27             DoEnter();
28         }
29 
30         private void btnCancel_BtnClick(object sender, EventArgs e)
31         {
32             DoEsc();
33         }
34 
35         protected override void DoEnter()
36         {
37             this.DialogResult = System.Windows.Forms.DialogResult.OK;
38             this.Close();
39         }
40 
41         private void FrmWithOKCancel1_VisibleChanged(object sender, EventArgs e)
42         {
43         }
44     }
45 }
View Code

相关文章:

  • 2021-08-29
  • 2021-07-14
  • 2021-11-18
  • 2021-12-07
  • 2021-11-18
  • 2021-11-18
  • 2021-11-15
  • 2021-07-02
猜你喜欢
  • 2021-11-01
  • 2021-09-26
  • 2021-12-09
  • 2021-06-15
  • 2022-01-24
  • 2021-11-18
  • 2021-11-07
相关资源
相似解决方案