Nexusfactor
February 4th, 2010, 10:13 AM
I have a small form with an update button, everytime the user clicks "Add price" I want 2 small text boxes to pop up right next to each other so the user could insert what is needed. If they wish to add another, they click "Add price" and another 2 boxes underneath the previous two show up and so on.
how would I implement that?
mariocatch
February 4th, 2010, 10:56 AM
Personally I would use WPF... but,
You can add a WrapPanel and set the width to enough where it can only contain two items per row.
Then, when Add Price is clicked, it would programatically add two textboxes.
I haven't used a WrapPanel in over a year, I'm assuming it has an Items collection but just look for whatever the container type is, and add TextBoxes that way.
wrapPanel1.Items.Add(new TextBox()) ;
wrapPanel1.Items.Add(new TextBox()) ;
However, another solution which may be better, is to create a new usercontrol which is the 2 textboxes. You could add this control over and over, and you can expose the textbox.text property of each textbox in it as you see fit.