Grid Autofit

Author: Kevin Cully

Posted: 2015-06-18 at 10:16:05

I'm working on a VFP form and I don't think I'm using a best practice

for AUTOFITting a grid. I've a pageframe with two pages, each page has

a grid. Many of these parent records have zero child sales records

and/or labor records. What's the best practice to get the grids to

AUTOFIT reliably?

Grids are set as:

ReadOnly = .T.

AllowCellSelection = .F.

In the THISFORM.LOAD() event, I create a cursor that I leave open for

the life of the form. When I navigate through the order records, I SQL

SELECT the child records, select the cursor that was created in the

LOAD(), ZAP it, and then append records from the cursor for the display

of the child records. This saves me from using views, and the

binding/unbinding problem with grids.

Here's the code I use to try to get that grid to autofit properly. This

code is *after* I've reloaded the records in the child cursor.

THISFORM.LockScreen = .T.

&& Lots of business stuff... including reloading the child cursor.

THISFORM.LockScreen = .F.

THISFORM.Pageframe1.Page1.grdSales.AutoFit()

THISFORM.Pageframe1.Page2.grdLabor.AutoFit()

THISFORM.Refresh()

The grids still aren't displayed with the optimized field sizes.

Harumph. Thanks for any help.

_______________________________________________

Post Messages to: ProFox@leafe.com

Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox

OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech

Searchable Archive: http://leafe.com/archives/search/profox

This message: http://leafe.com/archives/byMID/profox/5582E0B5.4080007@cullytechnologies.com

** All postings, unless explicitly stated otherwise, are the opinions of the author, and do not constitute legal or medical advice. This statement is added to the messages for those lawyers who are too stupid to see the obvious.

©2015 Kevin Cully