Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Optimizing the width of text grid controls
Message
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00564807
Message ID:
00564827
Views:
18
>Is it possible to optimize the width of text grid controls in a program?
>
>The scenario is that I have a grid where there is just enough room on the screen to display each row using the existing maximum length of data contained in each field. For example, when displaying a product's data, I found the item with the longest description and manually sized the control accordingly. I followed the same procedure for other read only controls. As mentioned above, when completed, the row just fits on the screen without scrolling.
>However, the data is not static and I would like the controls to automatically resize themselves everytime the form is run.
>Is this practical? possible?
>TIA.

Allan,
It's possible but I wouldn't necessarily do it when the form is initially run. You could have a trigger (e.g. header double click) that called this behavior. A query like:

select max(len(CurrentColumn.ControlSource) from Grid.RecordSource
resize column accordingly

If the table/cursor is relatively large, this could take a while which I why I recommend doing it only at the request of the user. Unless you wanted to create another table to hold maximum lengths for fields in tables. The table could be updated on a trigger when a user modifies the table in any way (insert/update/delete). The length calculations would be done at save so the user may/may not notice it. However, the layout calculations would be lightning fast.

FWIW, VFP.Next (Toledo) will have this capability built in. Calvin Hsai demonstrated it at the keynote in San Diego (or so I heard).
Larry Miller
MCSD
LWMiller3@verizon.net

Accumulate learning by study, understand what you learn by questioning. -- Mingjiao
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform