Form Fade Effect in WinForms App C#

form Fade Effect in C#

Form Fade Effect in WinForms: Adding simple animations in your desktop can enhance the user experience. You can add simple animations just by using simple programming tricks like Form Fade Effect in WinForms when opening or closing of your form.

Tools Required:

  1. Visual Studio 2010 or Later version.

Steps to Follow:

  1. If you have already created a windows forms applications project the skip to step 2. Or just create a brand new Windows forms application project in VS.
  2. Go to the design view of your form in which you want to add this simple Form Fade Effect. Add a timer control from the toolbox.
  3. For this tutorial we’ll just add this effect on closing of our form. But you can add this effect during opening of your form.
  4. Just go to the timer_tick event of the timer control and add the following code

if (this.Opacity > 0.0)
{
this.Opacity -= 0.025;
}
else
{
timer1.Stop();
Application.Exit();
}

  • Go to the OnClick event of the closing button. If you are not using the default closing button of WinForms. If you are using default layout, just select your form and goto OnClose event. And just call the start method of timer control like,

timer1.Start();

In the above technique, you noticed that we are just reducing the value of Opacity property of form. When tick event of timer occurs it reduces the opacity of form. Hence we’ve added simple form fade effect by using a simple technique.

Now you can try this technique to add the same effect on form opening event just by changing -= sign into +=. And call the start method on Form_Load event instead of form_Closing event. Also don’t forget to change greater than sign to less than in if condition.

Video Tutorial:

Watch this short video to learn how to add Form Fade Effect
in WinForms using this technique.

video tutorial

Source Code:

I hope You’ve enjoyed this Tutorial. Please don’t forget to subscribe our Official YouTube Channel C# Ui Aacdemy.

2 comments

  1. Hi there! This is my first visit to your blog! We are a team of volunteers and starting a new initiative in a community in the same niche. Your blog provided us valuable information to work on. You have done a wonderful job!

  2. Hi there,I was really looking for a detailed step by step guide to do this because I was really confused about doing this.Thanks a lot, buddy.Keep posting good stuff. Cheers.

Comments are closed.