0
我編寫了代碼以顯示右鍵單擊我的tabpages上下文菜單。當用戶從上下文菜單中點擊「刪除標籤」時,我將如何去實際刪除標籤頁?我已經得到了這個。 (unloadProfile是我的上下文菜單項)。我不確定如何獲取上下文菜單正在關聯的tab頁以將其刪除。任何幫助表示讚賞。如何從上下文菜單中刪除tabpage
// 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++)
{
}
}
很好用。謝謝。 – 2011-02-16 05:21:28