Hi,
I am working on a Windows Forms project. In that I have a form that needs to be dynamically populated controls by looping. At design time I kept one control for each controls(Text Box and Combobox controls) for those I would be generating dynamically. I am taking the name given to the static controls to the dynamically generated controls(like TextName1, TextName2). I could not be able to figure out those dynamic control names while saving? I aken those cOntrols on a panel control. Have any solution for this?
Loading
Scott LyslePosted Apr 15, 2007, 8:19 PM
public
Form1(){
InitializeComponent(); for (int i = 0; i < 10; i++)
{
Button b = new Button();
b.Text = "Button " + i;
b.Name = "Button" + i;
b.Click += new EventHandler(ButtonClicks);
b.Top = i * 30;
b.Left = 10;
this.Controls.Add(b);
}
} public void ButtonClicks(object sender, EventArgs e)
{
MessageBox.Show("You clicked on " + ((Button)(sender)).Name.ToString());
}