日期:2014-05-19  浏览次数:20904 次

ListView控件中的右键菜单问题
我在ListView中关联了一个ContextMenuStrip控件,发现在ListView中的任何地方右击时这个菜单都会出现。能不能只在ListView中的某一行上右击时才会出现菜单?

------解决方案--------------------
在ContextMenuStrip的Opening事件中检查listview是否有选中项,如果没有,则e.Cancel=true,就不会弹出来了~~~
------解决方案--------------------
ref:
http://www.codeproject.com/cs/miscctrl/ListViewContextMenu.asp?target=listview%7CContextMenu

Context Menu for ListView Column Manipulation