Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Listbox programmatically select & highlight
Message
 
 
To
29/06/2011 07:18:27
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:
01516710
Views:
129
>To the best of my recollection, setting the selected property of the listbox in the form's Init() does not work. This is a bug. You must choose a different method.
>
>PSS ID Number: 177340
>
>Article Last Modified on 12/11/1999
>
>
>--------------------------------------------------------------------------------
>The information in this article applies to:
>
>
>Microsoft Visual FoxPro for Windows 5.0
>Microsoft Visual FoxPro for Windows 5.0a
>Microsoft Visual FoxPro for Windows 6.0
>
>--------------------------------------------------------------------------------
>
>This article was previously published under Q177340
>
>SYMPTOMS
>In Visual FoxPro versions 5.x, programmatically using the Selected method to select an item in a list box does not work in the Init method of a list box or a form.
>RESOLUTION
>Use the following method to programmatically select an item in the Init method of a list box or a form:
>Thisform.List1.DisplayValue = Thisform.List1.List(1) && This will select
>&& the first item.
>
>STATUS
>Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. We are researching this bug and will post new information here in the Microsoft Knowledge Base as it becomes available.

Marcia,

Thanks for your follow-up.

I am using VFP 9. I do select items in my listbox (multiselect) in the form init method. And, that part works. When the SELECT statement it executed to populate the grid, it ueses the pre-selected values from the listbox successfully.

The problem I was having was that the pre-selected items in the listbox were not highlighted.

I have this working now. I am still selecting listbox items in the form init. But, I changed the way that I was populating the listbox: moved that code to the listbox init method, and used AddItem to populate the listbox instead of setting the RowSource to a cursor.

I don't know why this works, but I can't spend forever getting this "feature" of my form to work. Yikes!

Jim
Previous
Reply
Map
View

Click here to load this message in the networking platform