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,命名FrmWithOKCancel2,继承FrmWithTitle

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

 1 // 版权所有  黄正辉  交流群:568015492   QQ:623128629
 2 // 文件名称:FrmWithOKCancel2.cs
 3 // 创建日期:2019-08-15 16:05:21
 4 // 功能描述:FrmWithOKCancel2
 5 // 项目地址:https://gitee.com/kwwwvagaa/net_winform_custom_control
 6 
 7 using System;
 8 using System.Collections.Generic;
 9 using System.ComponentModel;
10 using System.Data;
11 using System.Drawing;
12 using System.Linq;
13 using System.Text;
14 using System.Windows.Forms;
15 
16 namespace HZH_Controls.Forms
17 {
18     [Designer("System.Windows.Forms.Design.ParentControlDesigner, System.Design", typeof(System.ComponentModel.Design.IDesigner))]
19     public partial class FrmWithOKCancel2 : FrmWithTitle
20     {
21         public FrmWithOKCancel2()
22         {
23             InitializeComponent();
24         }
25 
26         private void btnOK_BtnClick(object sender, EventArgs e)
27         {
28             DoEnter();
29         }
30 
31         private void btnCancel_BtnClick(object sender, EventArgs e)
32         {
33             DoEsc();
34         }
35 
36         protected override void DoEnter()
37         {
38             this.DialogResult = System.Windows.Forms.DialogResult.OK;
39         }
40 
41         private void FrmWithOKCancel2_VisibleChanged(object sender, EventArgs e)
42         {
43         }
44     }
45 }
View Code

相关文章:

  • 2019-08-22
  • 2021-11-28
  • 2021-11-01
  • 2021-12-19
  • 2021-11-18
  • 2021-11-18
  • 2021-11-28
  • 2021-08-29
猜你喜欢
  • 2021-11-28
  • 2021-11-18
  • 2021-11-18
  • 2021-11-18
  • 2021-11-28
  • 2021-11-18
  • 2021-11-11
  • 2021-11-18
相关资源
相似解决方案