tabcontrol在删除时删除所有控件并添加tabcontrol [英] tabcontrol remove all controls when remove and add tabcontrol

查看:113
本文介绍了tabcontrol在删除时删除所有控件并添加tabcontrol的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的先生



我在c#.net窗口基础应用程序中有一个标签控件。当我删除然后添加选项卡所有控件已删除时,请告诉我如何可见false标签页或如何使用标签添加删除。

解决方案

一个选项可以是在删除时将要隐藏/显示的TabPage保存到变量中,并在想要将其添加回来时引用该变量。

  //  变量以保存标签页 
private TabPage _hiddenTab = null ;



...

  //  将变量设置为您要删除的标签页 
_hiddenTab = (TabPage)tabControl1.Controls [ 1 ];
tabControl1.TabPages.Remove(_hiddenTab); // 删除标签



...

  //  将标签页添加回标签控件;如果它不为空 
如果(_ hiddenTab!= null
{
tabControl1.TabPages.Add(_hiddenTab);
_hiddenTab = null ;添加回制表符控件后 // 清除标签变量
}


Dear Sir

i have a tab control in c# .net window base application. when i remove and then add the tab all the controls has removed please tell me how to visible false the tab pages or how to use tab add remove.

解决方案

One option could be to save the TabPage you want to hide/show into a variable when you remove it and reference the variable when you want to add it back.

// variable to hold tab page
private TabPage _hiddenTab = null;


...

// set variable to tab page you are about to remove
_hiddenTab = (TabPage)tabControl1.Controls[1];
tabControl1.TabPages.Remove(_hiddenTab); // remove tab


...

// add tab page back to tab control; if it's not null
if (_hiddenTab != null)
{
    tabControl1.TabPages.Add(_hiddenTab);
    _hiddenTab = null; // clear tab variable after adding back to tab control
}


这篇关于tabcontrol在删除时删除所有控件并添加tabcontrol的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆