Using a loop to create multiple controls at runtime?
-
Is there a way that I could create multiple contols on a form using a loop? for loopcounter = 1 to 10 dim strControlName as string = "Button" dim objButton as new button() objbutton.name = strControlName & loopcounter form1.controls.add(objbutton) next Am I close? Please help! The Jazz Master 6000 DJ Badknees Parma Grind Crew - www.geocities.com/parmagrindcrew
-
Is there a way that I could create multiple contols on a form using a loop? for loopcounter = 1 to 10 dim strControlName as string = "Button" dim objButton as new button() objbutton.name = strControlName & loopcounter form1.controls.add(objbutton) next Am I close? Please help! The Jazz Master 6000 DJ Badknees Parma Grind Crew - www.geocities.com/parmagrindcrew
you would need to make the controls globally available ( not just on a sub or command button ) and also you would have to account for setting the positions of each item, which could become a bit of a headache. can you not add the controls at design time? it would save you a lot of bother.
Private void ExpectingTwins(string twins)
{
switch(twins)
{
Case ("twins on the way"):
MessageBox.Show("for mr and mrs dynamic","twins on the way");
break;
}
}
-
you would need to make the controls globally available ( not just on a sub or command button ) and also you would have to account for setting the positions of each item, which could become a bit of a headache. can you not add the controls at design time? it would save you a lot of bother.
Private void ExpectingTwins(string twins)
{
switch(twins)
{
Case ("twins on the way"):
MessageBox.Show("for mr and mrs dynamic","twins on the way");
break;
}
}
I was just wondering if it could be done, I realize that it would take some work to do the location of the controls. You said globally? Thanks! The Jazz Master 6000 DJ Badknees Parma Grind Crew - www.geocities.com/parmagrindcrew