I believe I may have found a solution to the problem of ListBox not holding the Selected(#) or SelectedId(#) attribute of individual items.
I often want to display a ListBox with certain items pre-selected.
The solution seems to be to put a short wait state, inkey(.2), between the population of the listbox and the selection routine.
It is as though the Init, Refresh and Activate, even GotFocus, methods of the form and control actually fire before the ListItem object is fully populated and ready to accept Selected property changes.
The same would need to be done after the rowsource property has changed or a requery() is called.
Good Luck!
Steve Ramsower
>Can someone enlighten me on this simple problem:
>
>I have a list box. In the ListBox.Init I put the following code.
>
>this.Selected(2) = .T.
>this.Selected(3) = .T.
>this.Refresh
>
>When the form is run, list items 2 & 3 are not shown as selected. If I run the same code from a command button on the form, it works as expected - the list items are selected. I have tried putting the code in the form.Init and form.Activate as well, with no success. My goal is to have a multi-select listbox which can be initialized to show the currently chosen items as 'selected'.
>
>Thanks for any help.
>Bill Sabo
Previous
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only