how to popup context menu

G

Guest

Hi,

I am a new bee in C#. (I am a VC++ programmer long time already.)

I want to display a context menu in ListView. And the context menu items
will be changed during runtime -- it depends on the location which user
clicked, for example, over ListItem or not.

Now I set an empty contexMenuStrip to ContextMenuStrip of ListView. And add
ToolStripItems into this empty contexMenuStrip during "Opening" event of
contextMenuStrip. But it does not look correct.

Anyone knows what I must do?

Best Regards,
Michael zhang
 
G

Guest

Hi,

First of all thanks for your reply.

Secondly, I have tried listView1_MouseClick. But this event only will be
fired when I right click on item.

And I have done one more test -- using listView_MouseDown and
listView_MouseUp with Capture=true. But if I right button down on an item in
listView, move the mouse out of the listview (even still in same form) and
release the right button. At this time I only receive one event
listView_MouseDown. -- it is ok for me. But when I move mouse back to the
ListView. A listView_MouseUp event will BE FIRED. So a context menu will be
displayed in this case.

Any good suggestion?

At the end thank you for your reply again.

Best Regards,
Michael zhang
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top