[英]How to save settings a TabControl with new TabPages? Visual Studio and C#
Add new pages: 添加新页面:
private void addToolStripMenuItem_Click(object sender, EventArgs e)
{
TabPage mytab = new TabPage();
mytab.Text = "New Tabpage";
tabControl2.TabPages.Add(mytab);
}
How to save settings for new tabpages in Form. 如何在表单中保存新标签页的设置。 I want to keep the new added tabs but I can not make them stay
我想保留新添加的标签,但不能让它们保留
All you really need to know is the number of TabPages
and, perhaps, the Text
for each one. 您真正需要知道的就是
TabPages
的数量,也许每个Text
数量。 In that case, all you need is either a single int
or else a StringCollection
in settings. 在这种情况下,您只需要一个
int
或设置中的StringCollection
。 If you use a StringCollection
, you'd loop through it and create a TabPage
for each item when loading and loop through the TabPages
and add an item when saving. 如果使用
StringCollection
,则将遍历它,并在加载时为每个项目创建一个TabPage
,并在TabPages
循环并在保存时添加一个项目。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.