Change image opacity at runtime in windows application

this is code how to change image opacity at runtime in windows application of .net

Changing image opacity at runtime

Hello friends here is the code for changing image opacity at runtime for which you have to use two timer controls. At first timer control tick event we are checking if opacity of form is greater than 1 or less than 0 then multiply tv variable by -1 make the opacity more.On timer2 tick event we are setting current form background image

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace WindowsApplication1
public partial class Form1 : Form
private float tv;
private int pno;
public Form1()
tv = 5;
pno = 1;

private void timer1_Tick(object sender, EventArgs e)
if (this.Opacity >= 1 || this.Opacity <= 0)
tv = tv * -1;
this.Opacity += tv / 100;

private void timer2_Tick(object sender, EventArgs e)
this.BackgroundImage = Image.FromFile("c:\\" + pno + ".jpg");

Related Articles

Write a Console Application for beginners

.NET framework contains Console application,Windows applications usually called as Win Apps,Web applications,Mobile applications,Web Services.Let us know how to write a simple Hello World using Console Application in the Visual Studio.NET framework tool 2008.

More articles: Change image opacity Image opacity Image transparency Windows application


No responses found. Be the first to comment...

  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name: