关闭标签 [英] Closing a Tab
问题描述
您好,我想获取一些代码来关闭表单外部的选项卡-这个概念是,当我单击关闭"时,会出现一个对话框,显示全部关闭",或者只是该选项卡-我已经整理了全部关闭的内容,但没有关闭标签页-但是我有一些代码可以关闭主窗体内的标签页,
Hi, I would like to get some code for closing a tab outside my form-the concept is that when I click close a dialogue comes up saying close all, or just this tab- I have sorted out close all, but not close tab- but I have some code for closing a tab inside the main form,
private void deleteTabToolStripMenuItem_Click(object sender, EventArgs e)
{
// Close the current tab, unless it happens to be the last one
if (current_tab_count < 2) return;
TabPage current_tab = tabControl2.SelectedTab;
WebBrowser thiswebpage = (WebBrowser)webpages[tabpages.IndexOf(current_tab)];
tabpages.Remove(current_tab);
tabControl2.TabPages.Remove(current_tab);
current_tab_count--;
}
我运行C#2010/.NET4.那么,有人可以帮助我吗?我有最后期限.
对不起,这不是我想要的!
我希望能够在其他窗体上关闭其主窗体上的选项卡!
将会有一个表单-一个新的表单,上面说关闭全部"或仅关闭"此标签,我希望能够使仅此标签"按钮仅关闭在其他表单上打开的那个标签-我已经有删除该文件夹的代码文件,但需要知道如何使它控制其他格式.
I run C# 2010/.NET 4. So, could anyone help me? I''ve got a deadline.
I''m sorry, that''s not what I''m looking for!
I want to be able to close a tab on my main form outside it- on a different form!
There will be a form- a new one that says close all or just this tab, i want to be able to make the just this tab button close just that tab that was open on a different form-I already have the code to delete a file, but need to know how to make it control a different form.
推荐答案
我会这样做:
I would do it something like this:
if (tabControl2.TabPages.Count > 2 && tabControl2.SelectedTab != null)
{
tabControl2.TabPages.Remove(tabControl2.SelectedTab);
}
这篇关于关闭标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!