WinForm——ContextMenuStrip总结

阅读 57

2022-03-20


  1. 使用举例

根据属的节点层次不同,右键列表的内容显示不同。

需要使用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)

{

         return;

}

if (node.Level>=1)

{

         contextMenuStrip1[“NewDish”].Visible=false;

         contextMenuStrip1[“Istart”].Visible=false;

}

}


精彩评论(0)

0 0 举报