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

准备工作

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

开始

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

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

 1 // 版权所有  黄正辉  交流群:568015492   QQ:623128629
 2 // 文件名称:FrmWaiting.cs
 3 // 创建日期:2019-08-15 16:05:09
 4 // 功能描述:FrmWaiting
 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     public partial class FrmWaiting : FrmBase
18     {
19         public string Msg { get { return label2.Text; } set { label2.Text = value; } }
20         public FrmWaiting()
21         {
22             base.SetStyle(ControlStyles.UserPaint, true);
23             base.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
24             base.SetStyle(ControlStyles.DoubleBuffer, true);
25             InitializeComponent();
26         }
27 
28         private void timer1_Tick(object sender, EventArgs e)
29         {
30             if (this.label1.ImageIndex == this.imageList1.Images.Count - 1)
31                 this.label1.ImageIndex = 0;
32             else
33                 this.label1.ImageIndex++;
34 
35         }
36 
37         private void FrmWaiting_VisibleChanged(object sender, EventArgs e)
38         {
39             //this.timer1.Enabled = this.Visible;
40         }
41 
42         protected override void DoEsc()
43         {
44 
45         }
46 
47         private void timer2_Tick(object sender, EventArgs e)
48         {
49             base.Opacity = 1.0;
50             this.timer2.Enabled = false;
51         }
52 
53         public void ShowForm(int intSleep = 1)
54         {
55             base.Opacity = 0.0;
56             if (intSleep <= 0)
57             {
58                 intSleep = 1;
59             }
60             base.Show();
61             this.timer2.Interval = intSleep;
62             this.timer2.Enabled = true;
63         }
64     }
65 }
View Code

相关文章:

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