Listbox multi row selection lost during debug?

Is it normal for this to happen?

  1. I select multiple rows in a listbox.
  2. I enter the debugger (actually to find out what is causing this problem)
  3. I return from the debugger to see all of the selected rows not selected.

I do have a cell lost focus event, but it doesn’t fire here.

Maybe… store the selected Row list in an array in a lost focus event and restore them in a got focus event ?

But, if this exists only o debug, not in the stand alone application, why bother ?

It does happen at an other time.
I have a message dialog that confirms the task because of selection, but I noticed nothing happened. My selection disappeared, because a message dialog had shown.

About the array.
That would work, but I cannot figure out what event to create the array under since selection can happen by mouse or keyboard.
I also.

So my question is what causes a selection to disappear?

When a MsgBox happens: the selected color change, but once you close the MsgBox, it get its color back.

You may try to create a simple project to demonstrate that. If the behavior is different, check your code.

FWIW: I just checked that behavior from a project here and the selected rows do not are unselected after a Message window appears (Quit for example / another window). So I think it is in your code.
(I took the code example from the LR MessageDialog for testing).

Thank you Emile.
I finally figure out what happened.
I had to sort out whether it was classes with events, or the Listbox.
I found eventually the window’s Activate event was reassigning the ListIndex, which caused the SelCount to return to 1.
This is necessary for the backup to the list to have the control of the ListIndex.

I changed the code from

If ArMnt <> Nil Then//Armnt is a class


If ArMnt <> Nil And AdCardList.SelCount < 2 Then//AdCardList is the Listbox 

So. Any other basic operations that I should include in the

If ArMnt <> Nil And AdCardList.SelCount < 2 Then