我已经编写了代码以在右键单击我的标签页时显示上下文菜单。当用户从上下文菜单中单击“删除标签”时,我将如何实际删除标签页?我已经走到这一步了。(unloadProfile 是我的上下文菜单项)。我不确定如何获取上下文菜单关联的标签页以将其删除。任何帮助表示赞赏。
// My Context Menu
private void tabControl_MouseClick(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Right)
{
// iterate through all the tab pages
for (int i = 0; i < tabControl.TabCount; i++)
{
// get their rectangle area and check if it contains the mouse cursor
Rectangle r = tabControl.GetTabRect(i);
if (r.Contains(e.Location))
{
// show the context menu here
this.contextMenuStrip1.Show(this.tabControl, e.Location);
}
}
}
}
// Context menu click event
private void unloadProfile_Click(object sender, EventArgs e)
{
// iterate through all the tab pages
for (int i = 0; i < tabControl.TabCount; i++)
{
}
}