Reputation: 29
I have four windows forms namely,
form1.vb,
form2.vb,
form3.vb,
form4.vb.
And also i have one master page namely form5.vb. So i have rotate one by one above four windows forms in form5.vb with every 20 secs . how to do it ?
Upvotes: 0
Views: 843
Reputation: 5928
Basically, you create a timer and call the function BringToFront on each form.
In C#:
static int counter = 1;
static void StartRotating()
{
System.Windows.Forms.Timer myTimer = new System.Windows.Forms.Timer();
myTimer.Interval = 20000; // 20 seconds
myTimer.Tick += new EventHandler(TimerEventProcessor);
myTimer.Start();
}
private static void TimerEventProcessor(Object myObject,
EventArgs myEventArgs) {
// you could use a switch statement also
if(counter==1) form1.BringToFront();
if(counter==2) form2.BringToFront();
if(counter==3) form3.BringToFront();
if(counter==4) {
form4.BringToFront();
counter=0; //reset counter
}
counter++;
}
Upvotes: 1
Reputation: 32701
You need to keep an index to know which form is currently displayed and then in the timer elapsed event you can do this
formtoshow.TopMost = true;
formtoshow.BringToFront();
Upvotes: 0
Reputation: 44306
On a 20 second timer you can call 'BringToFront
' on each form.
http://msdn.microsoft.com/en-us/library/system.windows.forms.control.bringtofront.aspx
Upvotes: 1