如何动态地创建标签 [英] How to Dynamically Create Tabs
问题描述
这是在C#
我需要基本上由textbox.Text做出的TabPages因此,例如:
I Need to basically make TabPages from a textbox.Text so for example:
textBox1.Text = "test";
TabPage textBox1.Text = new TabPage();
这就是我想要做的..我知道,不会直接工作,但应该给你我怎么想创建的TabPages ..然后我想能够太叫他们以后的想法,以便例如:
That is what i want to do.. i know that won't work directly, but that should give you the idea of how i want to create the tabPages.. then i want to be able to call them later on too so for example:
String browser = "browser 1";
(textBox1.Text as TabPage).Controls.Add(WebBrowser browser)
我需要所有名称是动态的,因为这是什么将是一个可以运行客户测试程序帐户会有它有帐号作为TabPage的控制名字一个TabControl,然后里面的每个那些个TabPage将是与其他的TabControl设立卡口与它自己的卡上每一invidivual测试左右的时间内标签标签基本上
I need all the names to be dynamic because what this will be is a program that can run tests for customer accounts There would be a TabControl which has the "Account Number as the tabPage control name and then inside each of those tabPages would be another TabControl with a set up tabs with each invidivual test in it's own tab. So Tabs within Tabs basically.
推荐答案
请它类似于这样:
var page = new TabPage(textBox1.Text);
var browser = new WebBrowser();
browser.Dock = DockStyle.Fill;
page.Controls.Add(browser);
tabControl1.TabPages.Add(page);
browser.Navigate("http://stackoverflow.com");
page.Select();
这篇关于如何动态地创建标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!