listbox SelectionType multiple not able to add more rows

First question: Is selcount zero or 1 based?

I think my question is “Where do I place “If selcount > 0 then Return””?
I have a listbox that I have a lot of events with code in it. I am also able to select multiple rows under certain conditions.

  1. Select a row with mouse-click.
  2. I hold down the shift key while mouse-clicking on another row, and I get multiple selections.
  3. a) I continue to hold the shift key and click on another next set of rows, then I get cellfocus and the multiple selection disappears.
  4. b) I continue to hold the shift key and use arrow keys, then I add rows.

What is likely the best solution? Add another property for multiple selection and have it in various places or is it some simple solution as above?

Anything count is 1 based. 0-count means none. We can’t really tell you where something needs to go, that’s an implementation detail that would change depending on what you are trying to do.

We would need more from you to help.
“Where do I place ‘If selcount > 0 then Return’ {when I am trying to do ______________________}”

Hmm. Hadn’t considered other options.

Note: I forgot to include in the if statement “with shift key held down” so multiple selection gets erased.

What other possibilities for “trying to do” are there?

Well, I guess I’m lost :stuck_out_tongue:

Let’s start with which event you are trying to return early out of?


What is it you’re trying to prevent?

I’m trying to stop the non-multiple selection.
If I’m selecting multiple rows which of these events could I have trouble with (or all)?
Mousedown (obvious)

Okay now things are starting to get more clear :slight_smile:

I’m narrowing it down, here are three ideas I think you’re trying to do. Could you clarify just a little more for me?

Are you:

  • Trying to prevent accidental misclicks from removing the whole selection?
  • Trying to prevent the selection of only one item (this could prove to be quite difficult for the very first item selected!)
  • Considering a method where a single click on each row adds to the selection (as if the ctrl key was continuously held)

I think it is mostly 1. I say it with think because when i click on a row it immediately goes to uhmm cellgotfocus. In other words the row is not first selected. I am not sure which is expected behavior. So that is an additional question.

When a row is selected, does it immediately go to cellfocus?

I also presume I am not trying to exclude many individual rows from being selected.

So. Yes prevent misclicks, but with the question could it be something else like the selection is immediately going to focus and should be doing something else?

Interesting note on going to cell focus. When I added breakpoints to various cell events, it went to row being selected.
Also, if I try to add a row with an arrow key, it does not add.
Also, if I mouse click on a row and have scrolled up or down, it won’t add to the selection

I solved part of my problem. I added to Listbox’s cellgotfocus to an If statement:
Keyboard.AsyncShiftKey = False

I tried adding it to other cell statements and got bad results.