ListBox, ContextualMenu and Multiple Selected Rows

Hi Folks,

I have a listbox in which I need to handle CellClick, Change, and ContextualMenu events and be able to process contextual Menu operations on SelCount = 0, SelCount = 1, and SelCount > 1.

If SelCount = 1 or SelCount = 0, then the Contextual Menu is handled properly. However, if the SelCount > 1, the selection is cleared and only the row under the mouse pointer is seen by the ConstructContextualMenu / ContextualMenuAction events.

I currently check for Contextual clicks in the CellClick event and Change event at the top of the event code by checking for IsContextualClick. In CellClick, I return False and in Change, I simply Return.

No matter what I do, the multiselection state is always being cleared.

In other projects where I do not need to handle Change, this works as expected, so I’m obviously missing something in how Change is retailed to the other two events.

As an aside, is there a good explanation for why Change is called if all the user has done is click a row?

Easy, because you might have changed the selection. The Change event is one of the events I most commonly implement.

You need to return true and process the contextual menu yourself via MenuItem.Popup.

Thanks, Tim.

Which leads to :

Should I be able to debug a call to myMenu.Popup? It seems that because the IDE is in front of the app, the menu popup call just drops through.

To debug a menuitem.popup situation, I’ve found that I must put a breakpoint on the call to myMenu.Popup, another BP on the line after the call, Run the project so the app is brought back to the front and then I can click the popup menu and go back to debugging.

Hmmm, maybe that’s a bug?