天天看點

WinForm——ContextMenuStrip總結

使用舉例

根據屬的節點層次不同,右鍵清單的内容顯示不同。

需要使用Opening事件。

private void contextMenuStrip1_Opening(object sender,CancelEventArgs e)

{

        TreeNode node=trw.SelectedNode;

        if (node==null)

        return;

}

Point p=tvw.PointToScreen(trw.Loction);

int y=node.Bounds.Y;

if (y<0||y>trv.Height)

if (node.Level>=1)

        contextMenuStrip1[“NewDish”].Visible=false;

        contextMenuStrip1[“Istart”].Visible=false;

繼續閱讀