I am having a form for that i want to change the background image of a form for every 10 seconds?

Posted by Sudheep.grandhe under C# on 11/4/2011 | Points: 10 | Views : 2394 | Status : [Member] | Replies : 9
Hi,

I am developing windows applications.I am having a form for that i want to change the background image of a form for every 10 seconds?can you please send the sample code.please do the needful.

Best,
Sudheep.



Responses

Posted by: Jayakumars on: 11/4/2011 [Member] [MVP] Bronze | Points: 25

Up
0
Down
hi
refer this url

http://www.dotnetspider.com/forum/298739-I-am-having-form-that-form-i-want-change-background-Images-every-sec.aspx

Mark as Answer if its helpful to you

Sudheep.grandhe, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sudheep.grandhe on: 11/4/2011 [Member] Starter | Points: 25

Up
0
Down
Hi,

I am asking about background image not background color.please send that code.

Best,
Sudheep.

Sudheep.grandhe, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Blessyjees on: 11/4/2011 [Member] Bronze | Points: 25

Up
0
Down
Hi,

try this
 private void timer1_Elapsed(object sender, System.Timers.ElapsedEventArgs e)

{
this.BackgroundImage = new Bitmap(@"D:\VS2010\PhotoFrame\Images\small\tiny2.jpg");
}


give the full path of the image, otherwise its not working.

Blessy Baby
Digitalmesh Softech pvt Ltd
https://blessybaby.wordpress.com/

Sudheep.grandhe, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sudheep.grandhe on: 11/4/2011 [Member] Starter | Points: 25

Up
0
Down
Hi,

For every 10 seconds it showing different images in the background of a form.

Best,
Sudheep.

Sudheep.grandhe, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Blessyjees on: 11/4/2011 [Member] Bronze | Points: 25

Up
0
Down
Hi,

You can use an array of images for this purpose and show each image on each time interval.

Blessy Baby
Digitalmesh Softech pvt Ltd
https://blessybaby.wordpress.com/

Sudheep.grandhe, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sudheep.grandhe on: 11/4/2011 [Member] Starter | Points: 25

Up
0
Down
HI,

Can you please send me the sample code.it is useful for me

Best,
Sudheep.

Sudheep.grandhe, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Blessyjees on: 11/4/2011 [Member] Bronze | Points: 25

Up
0
Down
Hi,

try this
int index=0;

private void timer1_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
string[] images = new string[]{@"D:\VS2010\PhotoFrame\Images\small\tiny2.jpg",
@"D:\VS2010\PhotoFrame\Images\small\tiny3.bmp",
@"D:\VS2010\PhotoFrame\Images\small\tiny4.jpg",
@"D:\VS2010\PhotoFrame\Images\small\tiny1.jpg"
};
if (index == images.Length) index = 0;
this.BackgroundImage = new Bitmap(images[index]);
index = index + 1;
}


Blessy Baby
Digitalmesh Softech pvt Ltd
https://blessybaby.wordpress.com/

Sudheep.grandhe, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sudheep.grandhe on: 11/4/2011 [Member] Starter | Points: 25

Up
0
Down
Hi,

In timer control .it shows only timer1_click event only shows.timer1_elapsed it doesn't shows this event.

Best,
Sudheep.

Sudheep.grandhe, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: NTurnbullJr on: 11/5/2011 [Member] Starter | Points: 25

Up
0
Down
If you want to start the timer, you can use code like this.

StartTimer(null, null);


System.Windows.Threading.DispatcherTimer myDispatcherTimer;

public void StartTimer(object o, RoutedEventArgs sender)
{
myDispatcherTimer = new System.Windows.Threading.DispatcherTimer();
myDispatcherTimer.Interval = new TimeSpan(0, 0, 0, 0, 10000); // 1000 Milliseconds = 1 second * 10 = 10000
myDispatcherTimer.Tick += new EventHandler(timer1_Elapsed);
myDispatcherTimer.Start();
}
Best regards,
Norm

Sudheep.grandhe, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response