Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
ListBox show Elements but not .F. when nothing to be sho
Message
From
04/06/2018 12:05:32
Walter Meester
HoogkarspelNetherlands
 
 
To
04/06/2018 05:03:47
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
General information
Forum:
Visual FoxPro
Category:
Object Oriented Programming
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows 10
Miscellaneous
Thread ID:
01660530
Message ID:
01660541
Views:
55
>>>>Hi,
>>>>
>>>>I have a listbox, populated with an array: Thisform.aNames
>>>>The list is restricted to the first 10 elements only so NumberOfElements is set 10
>>>>The array is constructed in myForm with aNames[10,2]
>>>>
>>>>and populated with a select:
Select naw.fullname, naw.ID from NAW where  substring(fullname,1) = ? m.lcLetter into array aNames[10.2]
>>>>this works fine, however, when there is not enough data to populate 10 fields the remaing are shown in the listbox as .F., how should I change to avoid this, prefer to show [ ] (nothing)
>>>
>>>Honestly I don't understand how that really works in the first place. I just tested thinking I might be wrong but that kind of syntax is giving me error ("SQL: Statement is invalid"). You can't really specify the array size, can you?
>>>Whatever the initial size of an array is, after the select statement it would be [selected rows count, columns count].
>>>
>>>
>>>Local array laCheck1[300,100], laCheck2[1]
>>>Select * from (_samples+'data\customer') into array laCheck1
>>>Select * from (_samples+'data\customer') into array laCheck2
>>>
>>>? Alen(laCheck1,1), Alen(laCheck1,2)
>>>? Alen(laCheck2,1), Alen(laCheck2,2)
>>>
>>>
>>>The only exception to this is when select doesn't return any rows. Then the array's original size and values are preserved.
>>
>>Correct, that is my case.
>>When one is working with the application for the first time, there are yet no records in the tables and this will result in 10 rows with .F. which I do not like.
>>So I will now parse through the array and replace all the .f. values with '' easy enough
>>
>>Thanks for your solution,
>>
>>Regards,
>>Koen
>
>Then you could simply set your array to be "" initially:
>
>
aNames = ''
>
>Elements then would all be '' instead of .F.
>
>However, I would repeat, SQL rowsource is the better alternative.
>
>PS: With SQL rowsource your ID would be an INT if that is an INT, not text that you need to make unnecessary conversions.

Hi Cetin,

I'd vote against that. It wil polute your datasessions with many cursors, one for each combobox. If by any chance you're repeating the alias you might end up with a situation that is difficult to debug
In our case our comoboxes have the aSource[1,2] property and we set the rowsourcetype to 5-array and the rowsource to THIS.aSource.
It also gives you and advangtage that you can fill the combobox from a datacache that is living in another datasession by passing the combobox to the caching manager.
The ID you need is simply in the contols' value property, so no need to refer to an alias.fieldname.

Walter,
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform