Context menu - Inserting an Item in a list

U

Udi

Hi,
I have a control "A" that displays a list of control "B".
How do I add the ability to insert a new "B" to the list through a
context menu?
I mean, What do I need to do in the event handler code?
Where do I find the location of the mouse when it was
right- clicked, and how do I find the relvant "B" that was clicked?

Thanks!
Udi.
 
O

Oliver Sturm

Udi said:
I have a control "A" that displays a list of control "B".
How do I add the ability to insert a new "B" to the list through a
context menu?
I mean, What do I need to do in the event handler code?
Where do I find the location of the mouse when it was
right- clicked, and how do I find the relvant "B" that was clicked?

Sorry, I can't tell you like this, because it depends on the control you
use to show the list. Usually, controls that can be used to display a list
of objects, like grids, list boxes and similar controls, have methods that
allow you to find out which entry is shown at a specific position. Or they
might even pass that information in to the mouse click event handler, so
you don't have to query it yourself.

The location of the mouse is the easy part: just use the MousePosition
property or Cursor.Position, alternatively. But note that these methods
give you the mouse position in screen coordinates - you'll probably need
to convert them to control coordinates, using the PointToClient method.


Oliver Sturm
 

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