Reputation: 27
I have problem displaying usercontrol
,I have a usercontrol
which has a panel called rowpanel
which has textbox
and combobox
,Now ,when I Click button_1
,I want the usercontrol
to be displayed on each click,it is like adding a row on each click,I just don`t know how to loop it,I tried using indexing...
CODE
private void button1_Click(object sender, EventArgs e)
{
AddRow add = new AddRow();
show_pnl.Controls.Add(add);
}
AddRow is usercontrol
...this is a windows application,can I get some help please,
Upvotes: 2
Views: 851
Reputation: 65534
The reason is because they are overlapping each other. To fix it increment the top &/or left as shown here:
private const int gap = 20;
private int count = 0;
private void button1_Click(object sender, EventArgs e)
{
var add = new UserControl1();
add.Top = count * (add.Height + gap);
show_pnl.Controls.Add(add);
count++;
}
Upvotes: 4