1 // after the program is opened, the form is gradually displayed from transparent to opaque.
2 // implementation method:
3. Add a Timer control (named fadeTimer in this example), and add the relevant code in FadeTimer_Tick to its Tick event.
4. Add the following code to the constructor of the Form class:
5 private bool showing = true;
6 public LoginForm ()
7 {
8 InitializeComponent ();
9
10 // form Display Effect
11 Opacity = 0.0; // the transparency of the form is 0.
12 fadeTimer. Start (); // Start time
13}
14
15 2. Tick event: Add the following control code:
16 private void FadeTimer_Tick (object sender, EventArgs e)
17 {
18 double d = 0.10;
19 if (showing)
20 {
21 if (Opacity + d >=1.0)
22 {
23 Opacity = 1.0;
24 fadeTimer. Stop ();
25}
26 else
27 {
28 Opacity + = d;
29}
30}
31 else
32 {
33 if (Opacity-d <= 0.0)
34 {
35 Opacity = 0.0;
36 fadeTimer. Stop ();
37} else
38 {
39 Opacity-= d;
40}
41}
42}