|
-
February 4th, 2010, 11:13 AM
#1
C# Forms and Text Boxes
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?
-
February 4th, 2010, 11:56 AM
#2
Re: C# Forms and Text Boxes
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.
Code:
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|