简体   繁体   中英

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.

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();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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