Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Listbox programmatically select & highlight
Message
 
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows 7
Network:
Windows 2003 Server
Database:
Visual FoxPro
Application:
Desktop
Miscellaneous
Thread ID:
01515590
Message ID:
01516557
Views:
66
>>Naomi,
>>
>>I may be a bit dense. I'm not sure what this is doing and how it will solve my problem. Could you clarify?
>>
>>Thanks,
>>Jim
>
>I think all that code I posted is irrelevant. There is nothing specific needed to make listbox show the selected items properly. Something else is at play in your particular case.

Naomi,

Thanks for a follow-up. I spent some time looking at your code, but couldn't see how it would help me.

To make sense of what follows, let me explain what this simple form does. The form has a listbox and a grid, and a couple of command buttons. The listbox allows the user to select parameters that are used in the SELECT statement that populates the grid.

So that the user doesn't have to always select items from the listbox everytime he runs the form, I save the current selections in the registry when the form closes, and then read them from the registry and pre-select them the next time the user runs the form. When the form starts up, the grid is populated, and with selected items in the listbox highlighted, he can see what parameters were used in the SELECT statement, and is then free to use others.

As I was debugging this, I could see that the selected items in the listbox highlighted, but as the program continued they didn't continue to stay highlighted. So, I experimented with setting the selected items from different places in the code.

To make a long story short, I added code to the listbox LostFocus method to select the items in the listbox (even though they had already been selected in the form init method). Now, When the form starts up, the grid is populated, and nothing is highlighted in the listbox. But, if I hit Tab, or Shift-Tab to move the focus, the listbox selections become highlighted and stay highlighted. Seems that when the listbox has the focus initially, the selected items are not highlighted. But, if I shift the focus to another control, the highlighting appears.

Any thoughts?

I do make note of your comments, and similar comments by Hugo that the problem must be elsewhere in my form. Right now, pretty hard to track down.

Again, thanks for your help.

Jim
Previous
Reply
Map
View

Click here to load this message in the networking platform