天天看点

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;

继续阅读