Dear All,
Another GUI Question. My form is like the picture below. There is a tabcontrol component with buttons and textbox. Each buttons has code inside.
Below, there are 2 components, textbox and button. When the textbox is filled with number, and expand is pressed, it will duplicate the tabpage into (number filled in the textbox) pages.
My question is : How to do this? Is this possible? I ve learned that we can make another form and call them if we want. This is similar but different.
Help me guys..thanks :)
(x)
Eryatronika
301
301
So by this example, there will be 6 duplicates of tabPage1 with the same buttons, textbox, and codes.

1 answers
The only way I can think of doing this without getting into an almighty mess is to clone the tab page and everything on it but to share the eventhandlers you've already coded for the controls on the first tab page, suitably adjusted so that you can tell which tabpage the control is on.
To do this, you'll need to first look at your InitializeComponent() method in the designer generated code in Form1.Designer.cs and then create your 'clone' method from that.
To give you a better idea of what to do, I've created a form containing a tab control (tabControl1), with one tab page (tabPage1) which contains only a textbox (tabTextBox) and a button (btnOne). I've also added a click handler for btnOne:
In addition, I added a textbox (textBox1) and an expand button (btnExpand) to the form itself as you've done.
From InitializeComponent(), I first copied this text out into Notepad:
Having done that, I then used the info therein to create a clone method within the form:
Incidentally, it shouldn't be necessary to set location and size properties for the tab page as the tab control seems to sort these out automatically when the tab page is added to its tabpages collection.
I then added this code in the expand button's Click handler:
Finally, I adjusted the code in btnOne's click handler, so that I could tell on which tab page the pressed button was on. This can be done using the sender parameter and then parsing the name of the control:
It worked surprisingly well :)
answered one year ago by:
17279
412
I'd suggest that Erya should use a dropdown list instead of a textbox. another thing I was wondering about was that why did u used a "Finite" integer (6) there????..... " if (num > 6) num = 6; "
17279
Better still would be a NumericUpDown. Not sure what you mean by a 'finite' integer? The maximum is around 2 billion but the tabcontrol would have blown up well before then! If you mean that you should take into account the existing number of tabs, then - yes - I agree that it would be better to set an overall maximum.