After the program is opened, the form is gradually displayed from transparent to opaque.
Implementation Method:
1. Add a Timer control (named fadeTimer in this example), and then add the relevant code in FadeTimer_Tick to its Tick event. That's easy.
Add the following code to the constructor of the Form class:
1 private bool showing = true;
2 public LoginForm ()
3 {
4 InitializeComponent ();
5
6 // special form Display Effect
7 Opacity = 0.0; // the transparency of the form is 0.
8 fadeTimer. Start (); // Start time
9}
2. Tick event: Add the following control code:
1 private void FadeTimer_Tick (object sender, EventArgs e)
2 {
3 double d = 0.10;
4 if (showing)
5 {
6 if (Opacity + d >=1.0)
7 {
8 Opacity = 1.0;
9 fadeTimer. Stop ();
10}
11 else
12 {
13 Opacity + = d;
14}
15}
16 else
17 {
18 if (Opacity-d <= 0.0)
19 {
20 Opacity = 0.0;
21 fadeTimer. Stop ();
22} else
23 {
24 Opacity-= d;
25}
26}
27}
Author Cheng Yao