Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Dale Dedoroy
  Where is Dale Dedoroy?
 Bacolod City, Negros Occidental
 Philippines
 Dale Dedoroy
 To: chris smith
  Where is chris smith?
 Yorkshire CH CH
 Barbados
 chris smith
 Tags
Subject: RE: grid column width
Thread ID: 727 Message ID: 731 # Views: 1 # Ratings: 0
Version: Unknown Category: General VFP Topics
Date: Tuesday, June 12, 2001 11:20:36 PM         
   


> How can I programmatically expand and contract the width of a grid column to match the length of the longest data element(number of charaters) in the column? The longest data element will vary.
> smith

Hi,
Try:

Local lnMaxLength
lnMaxLength = 0
Select MyTable && assumming MyTable is already used
Scan
lnMaxLength = IIf(Len(AllTrim(Trans(MyField))) > lnMaxLength,;
Len(AllTrim(Trans(MyField))),lnMaxLength)
EndScan
ThisForm.Grid1.Column1.Width = lnMaxLength + 10

Note: I did not test this code. Plus ten is needed to give margin allowance for those proportional fonts. Remove it if it's not necessary.

Hth,
Dale

ENTIRE THREAD

grid column width Posted by chris smith @ 6/12/2001 10:20:30 PM
RE: grid column width Posted by Dale Dedoroy @ 6/12/2001 11:20:36 PM
RE: What is trans() Posted by chris smith @ 6/13/2001 9:19:21 AM
RE: What is trans() Posted by Eric den Doop @ 6/13/2001 9:32:10 AM
RE: What is trans() Posted by chris smith @ 6/13/2001 10:18:53 AM
RE: What is trans() Posted by Dale Dedoroy @ 6/13/2001 8:30:08 PM
RE: Dale this is for you Posted by chris smith @ 6/14/2001 9:52:55 AM
RE: Dale this is for you Posted by Dale Dedoroy @ 6/14/2001 10:38:31 PM