C # several methods for implementing the form fade-in and fade-out effect

Source: Internet
Author: User

1.

Private void form1_load (Object sender, system. eventargs E)
For (double D = 0.01; D <1; D + = 0.02)
{
System. Threading. thread. Sleep (1 );
Application. doevents ();
This. Opacity = D;
This. Refresh ();
}

 

2.

Private void timerjavastick (Object sender, system. eventargs E)
{
This. Opacity = winshow;
Winshow ++ = 0.1;
If (winshow> = 1)
{
Timer1.dispose ();
}
}

 

3.

Use a loop or timer,
Frmform myform = new frmform ()
Frmform. Opacity = 0;
Frmform. Show ();
For (INT I = 0; I <100; I ++)
{
Application. doevents ()
Frmform. Opacity = I/100;
}

 

4.

# Region ******** form fade-in effect function ********
Private double winshow = 0; // variable used for window fade-in effect

Private void formshow (system. Windows. Forms. Form curfrm)
{
Curfrm. Opacity = winshow;
Winshow ++ = 0.01;
If (winshow = 1)
{
Curfrm. timershow. Stop ();
}
}

# Endregion

# Region ******** example of function calling for form fade-in effect ********
// Implement the fade-in effect of the window
Private void timershow_tick (Object sender, system. eventargs E)
{
// Timershow, which is the name of the timer control. Set timershow. interval to 100.
Formshow (this );
}
# Endregion

Http://publishblog.blogchina.com/blog/tb. B? Diaryid = 5564742

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.