Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This feels to me like a "homework" question, so I am going to answer by (I hope) giving you just a few pointers to solving this for yourself.</p> <p>Phase One</p> <ol> <li>create a sample project with a ListBox</li> <li>define event handlers for MouseClick, MouseDown, and Click events.</li> <li>put a Console.WriteLine("some appropriate text"); statement in each of those handlers so you can look in the Output Window in Visual Studio and see which event handler was called.</li> </ol> <p>...</p> <p>Phase Two</p> <ol start="4"> <li><p>run the test program and observe the difference between what events are reported for a left mouse down and a right-mouse down (assuming your environment has the context click set to the right mouse down ... which may not be true for everyone).</p></li> <li><p>focus on the one event you can intercept with a context-click.</p></li> <li><p>add a context menu to the test project and set that context menu to be the context menu of the ListBox.</p></li> <li><p>verify that you can now right click on an item in the ListBox and that the context menu will appear, BUT THE EVENT IS STILL HANDLED BY THE HANDLER YOU "DISCOVERED" IN STEP 2.</p></li> <li><p>now go through all the Event handlers for ListBox, and figure out which one could be used to detect, given a certain location in the ListBox, which List Item was "hit."</p></li> <li><p>once you can determine which List Item was right-clicked on, and you know your context menu is working, you have only the problem of making sure that the right-clicked List Item is selected : and that's pretty easy.</p></li> </ol> <p>Figuring this out yourself will teach you several very useful things you'll be able to use later in programming to other controls.</p> <p>best of luck, Bill</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload