Click here to Skip to main content
15,881,803 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi my name is Vishal i was wondering on how to create control array of timer control in c# windows forms?
Can anyone show me a sample on how to create a control array of timer and manipulate in program as we can do in vb6 with Ms access in c# windows forms with sql server 2008.

I just want a sample on how to create a control array of timer control in c# windows forms? Can anyone show me sample on how to create control array of timer control in c# windows forms? Can anyone guide me on how to create control array of timer control in c# windows forms? Any help/guidance in creation of control array of timer control in c# windows forms would be greatly appreciated!
Can anyone help me please!?
Posted

1 solution

Yes, you can create a Control array in C# see below example Hope it will help you.

1. Create a New Windows Forms Project and add a button on it. Copy the below code and paste

C#
//Timer Array Declaration
Timer[] timerex = new Timer[5];

Private void button1_click(object  sender, EventArgs e)
{
   for (int i=0;i > timerex.Length; i++)
    {
     timerex[i] = new Timer();
     timerex[i].Interval = 1000;
     timerex[i].Start;
     timerex[i].Enabled = true;
     timerex[i].Tag[i] = i;
     timerex[i].Tick += new EventHandler(Form1_Tick);
    }
}

void Form1_Tick (Object sender,EventArgs e)
{
  int senderex = system.convert.ToInt32(((Timer)sender).Tag.ToString());
  timerex[senderex].Stop;
  MessageBox.Show("Timer {0}is called",senderex.ToString());
}
 
Share this answer
 
Comments
Member 10248768 30-Jun-14 6:36am    
Thank you Mr.Rohit R Chavan
Thank you answering to my query on such short notice. I know that you are correct. I will try to implement the concept in my c# win forms project as soon as possible and will let you know.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900