Listbox: Removing the only row selection

And another stupid question:

I have a listbox with multiple selection enabled. When the user clicks on one row, I scan the listbox for selected rows because I need to change the caption of a Pushbox (it enables the user to put the selected rows into the clipboard. If none are, the entire listbox will be pushed to the clipboard.)

Everything works fine, except for one thing: When there is only one row selected and I click on it, the push box caption is set correctly to “all”. But the row stays selected no matter what I try – only if I return true from the cell click event it gets unselected, but then one cannot rearrange the rows anymore which needs to be enabled. What do I miss?

Function CellClick(row as Integer, column as Integer, x as Integer, y as Integer) As Boolean dim sel as boolean me.Selected (row)= not (me.selected (row)) // to invert the state of the currently clicked row for q as integer = 0 to me.ListCount -1 if me.Selected(q) then sel = true next if sel then PushButton1.Caption = "Ausgewählte in Zwischenablage" else PushButton1.Caption = "Alle in Zwischenablage" end if // if I invert the row state again, hoping the system will then disable it, everything stays the same. return false // because the user needs to be able to drag the rows End Function

Why not update the PushButton.Caption in the Change event?

Sub Change() If Me.SelCount = 0 Then PushButton1.Caption = "Alle in Zwischenablage" Else PushButton1.Caption = "Ausgewhlte in Zwischenablage" End End Sub

Simple answer: Because the event description reads "Fires in the following situations: " (and nothing more.)
Therefore I ignored it. :wink:

Hey, that’s easy! Thanks a lot, Eli!

Do file a Feedback case about that. It ought to be pulling from what is in the Language Reference for ListBox.Change.

Done that: 33071.