M
MojiPPT
Guest
Hey there! I'm currently trying to make a tab system that will copy components to each tab made. I need to copy over more than one button, but the code I have currently is only allowing me to generate one of each component. This is a sample that I recreated from my original project to see if it was an isolated issue, but it does the same thing. (Added comments in hopes that it can help anyone who's willing to help me)
//dynamically generate components
TabPage Tab = new TabPage("Tab");
Button b1 = new Button();
Button b2 = new Button();
//button to add tab
private void button1_Click(object sender, EventArgs e)
{
//make a new tab in the thingy
tabControl1.TabPages.Add(Tab);
//add components to tab
Tab.Controls.Add(b1);
Tab.Controls.Add(b2);
//make an eventhandler for each button's click event
b1.Click += new EventHandler(b1_Click);
b2.Click += new EventHandler(b2_Click);
}
private void b1_Click(object sender, EventArgs e)
{
//b1 click
MessageBox.Show("b1");
}
private void b2_Click(object sender, EventArgs e)
{
//b2 click
MessageBox.Show("b2");
}
Continue reading...
//dynamically generate components
TabPage Tab = new TabPage("Tab");
Button b1 = new Button();
Button b2 = new Button();
//button to add tab
private void button1_Click(object sender, EventArgs e)
{
//make a new tab in the thingy
tabControl1.TabPages.Add(Tab);
//add components to tab
Tab.Controls.Add(b1);
Tab.Controls.Add(b2);
//make an eventhandler for each button's click event
b1.Click += new EventHandler(b1_Click);
b2.Click += new EventHandler(b2_Click);
}
private void b1_Click(object sender, EventArgs e)
{
//b1 click
MessageBox.Show("b1");
}
private void b2_Click(object sender, EventArgs e)
{
//b2 click
MessageBox.Show("b2");
}
Continue reading...