I googled this and still cant get it to work. I know how to add a tab using the toolbox. I have also read about how to do it programmatically, but i still dont get it. (MSVC# Express 2010)
I have an easy project set up. Just a windows Form with a TabControl in it, i used the Designer to add a new TabControl and made that TabControl public instead of private.
I wrote this code to
a) access the Windows Form
b) add a tabpage.
The code compiles just fine, but the Tabpage is not displayed during runtime.
static class Program
{
[STAThread]
static void Main()
{
Application.SetCompatibleTextRenderingDefault(false);
Application.EnableVisualStyles();
Form1 ApplicationMainForm = new Form1();
Application.Run(ApplicationMainForm); //LABEL B
ApplicationMainForm.tabControl1.TabPages.Add("MyPage"); //LABEL A
}
}
How can i get the form to display my Tabpage?
My TabPage is displayed when the Lines A and B change position. Am i missing an update method, oder is the TabPage Add never called until the application closes?
Edit #1: Some minor edits.
Edit #2: Edited in some more examplecode.
Edit #3: Removed some earlier / irelevant points.
Edit #4: Found a hint and edited this information in
The tab control is a collection of tab pages, so you add tab pages like you add any control to a collection. Note that the tabs show up in the order you add them.