Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Programatically Determine List.ColumnWidths
Message
 
 
À
26/07/2007 14:05:23
Dragan Nedeljkovich (En ligne)
Now officially retired
Zrenjanin, Serbia
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
01243619
Message ID:
01243881
Vues:
22
>>>>I need to load a list box in a SCAN/ENDSCAN.
>>>>
>>>>Some columns may or may not be visible, so I want to set the ColumnWidths property
>>>>from the data.
>>>>
>>>>How do I calculate the ListBox ColumnWidth? I could use FONTMETRIC(6,,) * FSIZE(), but that
>>>>would result in some really wide columns in the listbox.
>>>
>>>You could calculate max(txtwidth(alltrim(yourfield), listbox.fontname, listbox.fontsize, "N"), that would give you a pretty good estimate. Add a few pixels for margin.
>>
>>Hi Dragan,
>>
>>I think the confusing part was the ALLTRIM here. Why do we need to use ALLTRIM and not the whole width of the field?
>
>I figured his problem was that the default would be too wide if even the longest string had too many trailing spaces. So this was to emulate grid's autofit.

You're right. You actually mentioned FONTMETRIC in your first reply too. It just took me some time (about 2 minutes, I guess) to figure this as well.
If it's not broken, fix it until it is.


My Blog
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform