Keeping the "CurrentSelection" in Listbox controls when re-entering modal form

Started by Carsten, January 09, 2017, 09:17:07 AM

Previous topic - Next topic

Carsten

Hi Forum,

just asking for a quick feed-back on whether I understand correctly the nature of the "CurrentSelection" in the ListBox control:
When "re-entering" a modal form the "List" property of the ListBox is still remembered, so it is populated with the same items as before the "Form_close"
But the "CurrentSelection" returns -1, even though an item was selected before the form was closed.

I guess it has to do with the "CurrentSelection" of the ListBox not being a Property but something else?
Therefore it is necessary to have variables for the current selections of all ListBox's so that user selections from before the "Form_Close" can be re-established?
(Which is just what I am trying to avoid).

Thanks in advance
Carsten

owenwengerd

You are correct, that there is no property for current selection, or selection of any kind. Selection state is something handled entirely by the list box control itself. Therefore, an instance of a list box control must exist in order for "selection" to have any meaning. When the control goes away, so does selection state.

Indeed, your own code is free to define a "current selection" and apply it during OnInitialize.
Owen Wengerd (Outside The Box) / ManuSoft

Carsten

Thanks for response.
No problem to maintain the CurrentSelection through the code, just wanted to make sure I was not coding something which could already be handled by the control.

BR
Carsten