2017-10-06 81 views
0

我有一些tooltrip菜單項,下面有一些其他的tooltrip菜單項。我如何處理第一個工具欄菜單(父),以便在某些條件滿足時不打開並顯示孩子。toolstripmenu拉手下拉

所以我有:

Documents: (parent toolstrip item) 
----Document1 (child) 
----Document2 (child) 
----DOcument3 (child) 

documentsToolStripMenuItem_Click(object sender, EventArgs e)我有

if(CurrentUser.HasPermission(0001)) 
{ 
    MessageBox.Show("You do not have permission to access this module!"); 
    //Here i need to prevent showing children of this parent 
} 

所以總結起來,用戶需要允許按父工具條菜單項(文檔),當他按下它,沒有權利,我不想讓他看到那個父母下面是什麼(這是孩子)。

我知道我可以使該工具欄菜單隱藏或enabled = false但我有其他的東西,因爲它需要點擊。

+0

建立依賴於用戶的權限菜單,則不需要進一步的檢查。 – dcg

+0

我寫道,我需要看到有按鈕,我需要被允許點擊,即使我沒有權限 – DoLoop

回答

0

你將不得不使用DropDownOpening事件:

void parentItem_DropDownOpening(object sender, EventArgs e) { 
    allowedItem.Visible = true; 
    notAllowedItem.Visible = false; 
} 
+0

哦,謝謝你給了我主意。我將只設置不允許項目的可見屬性,而不是設置評論我需要放置的東西。謝謝。 – DoLoop