I have a flowlayout panel containing 3objects(containing checkbox and textbox) while form loading. I have a button ADD, when ever user clicks add he gets input box and enter some number. i have to add that number of objects to flowlayout along with old 3objects.
for (int i = 0; i < iParseCount; i++)
{
UserPattern oUserPattern = new UserPattern("userDefParser" + (i+1));
pnlUserPattern.Controls.Add(oUserPattern);
}
here pnlUserPattern is the flowlayout panel.
problem is only intial 3 objects are showing.
Any help please..........
thanks in advance.
Vasu.
Marimuthu ArigovindasamyPosted Jun 8, 2010, 2:19 AM
When U add the 'n' objects in the Panel control, due to the control size, it may not be visible to you. (Can confirm from the Panel controls count, it's added successfully).
Using the below code, you can test whether the objects are added successfully or not.
foreach (Control subctrl in ((Panel)panel1).Controls)
{
if (subctrl is TextBox)
{
MessageBox.Show(subctrl.Name);
}
else if (subctrl is CheckBox)
{
MessageBox.Show(subctrl.Name);
}
}
If still not getting, pls attach ur code in this.
vasu babuPosted Jun 7, 2010, 4:53 AM
Marimuthu ArigovindasamyPosted Jun 7, 2010, 3:09 AM
No idea about your UserPattern function. Might be, the control is added successfully and not visible due to the control size.
Can you try to set the dynamic control size and location as below (You can set the AutoScroll property of panel control to True)
for (int i = 0; i < iValue; i++)
{
Label lblComment = new Label();
lblComment.Name = string.Concat("lbl", i);
lblComment.Text = chartName;
lblComment.Size = new Size(150, 13);
TextBox txtComment = new TextBox();
txtComment.Name = string.Concat("txt", i);
txtComment.Multiline = true;
txtComment.Size = new Size(303, 20);
lblComment.Location = new Point(20, 30);
txtComment.Location = new Point(50, 70);
pnlComments.Controls.Add(lblComment);
pnlComments.Controls.Add(txtComment);
}