简体   繁体   English

如何将上下文菜单添加到supertabControl

[英]How to add a context menu to a supertabControl

I'm using DotNetBar component SuperTabControl , and I want to display the context menu if the user right click a tab, I found the following code but the problem is my SuperTabControl doesn't have the GetTabRect function. 我正在使用DotNetBar组件SuperTabControl ,如果用户右键单击选项卡,我想显示上下文菜单,我找到了以下代码,但是问题是我的SuperTabControl没有GetTabRect函数。

if (e.Button == MouseButtons.Right)
            {
                for (int i = 0; i < this.superTabControl1.Tabs.Count; ++i)
                {
                    Rectangle r = this.superTabControl1.GetTabRect(i);
                    if (r.Contains(e.Location))
                    {
                       //display menu 
                    }
                }
            } 

As long as there is no answer for my question, I used this code in order to manage closing tabs basing on selected option on my context menu. 只要我的问题没有答案,我就使用此代码来管理基于上下文菜单中所选选项的关闭选项卡。 To close all the tabs except the seelcted one I used this code. 要关闭所有选项卡,除了封闭的选项卡,我使用了此代码。

for (int i = this.superTabControl1.Tabs.Count - 1; i >= 0; i--)
            {
                BaseItem item = this.superTabControl1.Tabs[i];
                if (!item.Equals(this.superTabControl1.SelectedTab))
                {
                    (item as SuperTabItem).Close();
                }
            }

To close all the tabs. 关闭所有标签。

 for (int i = this.superTabControl1.Tabs.Count - 1; i > 0; i--)
            {
                BaseItem item = this.superTabControl1.Tabs[i];
                (item as SuperTabItem).Close();
            }

To close the selected Tab I used this code: 要关闭所选标签,我使用了以下代码:

this.superTabControl1.SelectedTab.Close();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM