Reputation: 77
When I create a tabpage at runtime how can I call that same tabpage at a different runtime sequence? SelectedTab = "newPage"
? newPage is not a collection I made at design time so it's not a part of collections. newPage is created only at runtime. It's for a Windows Form program Visual studio 2010
Thanks in advance and I hope you can help.
Upvotes: 0
Views: 4083
Reputation: 11687
Don't have Visual Studio installed on my system yet, waiting for IT guys....but will try for a quick pointer.
TabPage tp = new TabPage();
tp.Name="MyTabPage";
tabControl.Controls.Add(tp);
To select your tabpage, you need to refer "tp"(tabPage variable) but NOT "MyTabPage"(name of tabpage).
tabControl1.SelectedTab = tp;
If they are being used in different methods or classes, try to use the properties. Hope it helps.
Upvotes: 1