Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

how to fade c# form

Timer t1 = new Timer();

private void Form1_Load(object sender, EventArgs e)
{
            Opacity = 0;      //first the opacity is 0

            t1.Interval = 10;  //we'll increase the opacity every 10ms
            t1.Tick += new EventHandler(fadeIn);  //this calls the function that changes opacity 
            t1.Start(); 
}

void fadeIn(object sender, EventArgs e)
{
            if (Opacity >= 1)  
                t1.Stop();   //this stops the timer if the form is completely displayed
            else
                Opacity += 0.05;
}
 
PREVIOUS NEXT
Tagged: #fade #form
ADD COMMENT
Topic
Name
4+5 =