Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Grid's AutoFit - Hope it is a little contribution here

Status
Not open for further replies.

benman

Programmer
May 3, 2006
35
HK
Dear All:

I reviewed part of the thread here mentioning Grid's AutoFit function.

To my understanding, that grid.autofit would fit column's width accordingly to current displaying records.....

It is hard to explain. anyway, here is little coding for your reference in grid.init for your comment and correction:

Code:
** SCAN ALL RECORDS TO FIND MAX WIDTH OF COLUMN

LOCAL laWidth(FCOUNT()) as Number
FOR nCount = 1 TO FCOUNT()
	laWidth(nCount) = 1
ENDFOR

nRowNumber = FLOOR(((this.Height - this.HeaderHeight) / this.RowHeight ))
nPages = CEILING(RECCOUNT() / nRowNumber)

thisform.LockScreen = .T.
GO TOP
this.AutoFit
this.Refresh
FOR nCount = 1 TO nPages
	IF EOF()
		GO bottom
		SKIP -nRowNumber + 1
	ENDIF
	this.Autofit
	this.Refresh
	FOR nCount2 = 1 TO FCOUNT()
		laWidth(nCount2) = MAX(laWidth(nCount2), this.Columns(nCount2).Width)
	ENDFOR
	SKIP nRowNumber
ENDFOR
FOR nCount2 = 1 TO FCOUNT()
	this.Columns(nCount2).Width = laWidth(nCount2)
ENDFOR
GO top
this.refresh
THISFORM.LockScreen = .F.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top