从内部关闭TabPage [英] Close TabPage From Within Itself

查看:89
本文介绍了从内部关闭TabPage的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

美好的一天所有!!!



我有一个tabcontrol,我正在动态添加tabpages。我想知道如何从内部关闭标签页。我在tabpage中托管一个控件,该控件具有关闭tabpage的菜单选项。我该怎么做呢。



提前完成...

Good day all!!!

I have a tabcontrol that I'm dynamically adding tabpages to. I wanted to find out how do I close the tabpage from within itself. I'm hosting a control inside the tabpage that has the menu option to close the tabpage. How would I go about doing this.

Thanx in advance...

推荐答案

没有标签页面的关闭概念。您可以删除一个,方法如下:

http://msdn.microsoft.com/en-us/library/system.windows.forms.tabcontrol.tabpages.aspx [ ^ ],

http://msdn.microsoft.com/en-us/library/system.windows.forms.tabcontrol .tabpagecollection.aspx [ ^ ],

http://msdn.microsoft.com/en-us/library/system.windows.forms.tabcontrol.tabpagecollection.remove.aspx [ ^ ]或:

http://msdn.microsoft.com/en-us/library/system。 windows.forms.tabcontrol.tabpagecollection.removeat.aspx [ ^ ]。



注意,没有从内部这样的东西或不。通常,您调用一些事件,事件处理程序是匿名方法或通常是窗体或窗口的方法。例如:

There is no such concept as "close" for a tab page. You can delete one, here is how:
http://msdn.microsoft.com/en-us/library/system.windows.forms.tabcontrol.tabpages.aspx[^],
http://msdn.microsoft.com/en-us/library/system.windows.forms.tabcontrol.tabpagecollection.aspx[^],
http://msdn.microsoft.com/en-us/library/system.windows.forms.tabcontrol.tabpagecollection.remove.aspx[^] or:
http://msdn.microsoft.com/en-us/library/system.windows.forms.tabcontrol.tabpagecollection.removeat.aspx[^].

Note, that there is no such thing as "from within itself" or not. Typically, you invoke some events, and the event handler is an anonymous method or a method of, typically, a form or a window. For example:
myDeleteButton.Click += (sender, eventArgs) => { // or menu item click, same thing...
    myTabControl.TabPages.RemoveAt(myTabControl.SelectedIndex);
    // if myDeleteButton is placed on some page, and you can click it, it means that the page is selected before the click
    // this button itself will be removed with the page, as the result of this action,
    // so what?
};





上面的引用是针对 System.Windows.Forms ,但是WPF(可能还有其他一些库)的代码非常相似。



注意:你应该始终标记UI所用的UI库或应用程序类型参与。



-SA



The references above are for System.Windows.Forms, but the code for WPF (and probably some other libraries) will be very similar.

Note: you should always tag the UI library or application type you are using when UI is involved.

—SA


这篇关于从内部关闭TabPage的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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