选项卡控制问题(C#)帮助我... [英] tab controlling problem (c#) help me guys...
问题描述
大家好..
我是新来的.我在使用Tab键控制时遇到了一些问题.这是问题所在...
我在表单中添加了一个带有3个标签的新标签控件.我想在默认视图上隐藏tabpage2,所以我在formload事件中编写了tabpage2.dispose()方法.
现在我想通过单击位于tabpage1中的按钮来查看该页面.(tabpage1是默认视图),所以我写道,
1. tabpage2.show();
2. tabcontrol.selectedtab = tabpage2;
3. tabpage2.select();
但是我再也无法获取该标签页.所以,现在该怎么办?
hi everyone..
I''m new here. i got a little problem with tab controlling.here is the problem...
I''ve added a new tab control with 3 tabs to my form. i want to hide tabpage2 on default view so I wrote tabpage2.dispose() method in formload event.
now I want to view that page by clicking a button placed in tabpage1.(tabpage1 is the default view) so i wrote,
1. tabpage2.show();
2. tabcontrol.selectedtab = tabpage2;
3. tabpage2.select();
but I couldn''t get that tabpage again.so, what should I do now??
推荐答案
使用Hide
函数而不是处理.只需将其标记为垃圾收集即可处理,然后就无法调用
改进的答案
您可以像这个例子一样.
Use theHide
function instead of dispose. Dispose simply mark it for garbage collection and then it is not available for call
Improved Answer
You can do like this example.
public partial class Form1 : Form
{
TabPage t1;
private void Form1_Load(object sender, EventArgs e)
{
t1 = tabControl1.TabPages[1];
tabControl1.TabPages.RemoveAt(1);
}
private void button1_Click(object sender, EventArgs e)
{
tabControl1.TabPages.Insert(1, t1);
}
}
首先,Dispose
方法将释放所有资源,从而丢失所有数据.
如果要隐藏tabpage
,则应调用Hide
方法.
有关更多信息,请检查 MSDN
First of all, theDispose
method will release all the resources, thus losing all the data.
If you want to hide atabpage
you should call theHide
method.
For further information please check MSDN
这篇关于选项卡控制问题(C#)帮助我...的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!