creating runtime tabpages with runtime controls C#

E

Elp

rp said:
Hi,

How would I create runtime tabpages with runtime
controls(textBoxes,comboBox, checkedListBox), inserting,deleting, and
modifing the tabpages whenever I want to in C#? Thanks in advance.

You do all that in the designer and then have a look at the generated code
to understand how to do it programmatically.

For example, to create a tab page and add it to your tab control tabControl:
TabPage page = new TabPage("My new tab");
tabControl.Controls.Add(page);

To create a button and dock it on the bottom of your tab page:
Button button = new Button();
button.Text = "Test Button";
button.Dock = DockStyle.Bottom;
page.Controls.Add(button);

To remove this button from your tab page:
page.Controls.Remove(button);

Note that to be able to modify your controls anytime during runtime, you
need to keep a reference to them somewhere. You could for example make them
member variables of your class. There are of course also plenty of other
solutions to add, remove, modify and get references to your controls at
runtime. Have a look at the doc of all the controls you need.
 
R

rp

Hi,

How would I create runtime tabpages with runtime
controls(textBoxes,comboBox, checkedListBox), inserting,deleting, and
modifing the tabpages whenever I want to in C#? Thanks in advance.

rp
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top