I approach this problem by setting up an auxiliary formatting table containing the fields: FieldName, RealName, FieldSize. FieldName is the actual cursor field name, RealName is the name I want to see in the grid display.
I set the grid formatting properties by scanning through the formatting table, as show below.
* Format grdGrid Headings
THIS.PARENT.grdGrid.SETALL("FontName", "Arial", "Header")
THIS.PARENT.grdGrid.SETALL("FontSize", 8, "Header")
THIS.PARENT.grdGrid.SETALL("FontBold", .T., "Header")
THIS.PARENT.grdGrid.SETALL("FontCondense", .T., "Header")
nScaleMult = 8 && to match the font size
nFieldNum = 0
* Format the grid data.
SCAN
nFieldNum = nFieldNum + 1
* Get the caption for the grid column.
cUsedName = ALLTRIM(IIF(EMPTY(RealName),FieldName,RealName))
THIS.PARENT.grdGrid.COLUMNS(nFieldNum).Header1.CAPTION = UPPER(cUsedName)
* Make the field size the larger of the field size or the caption length, but no less than 30.
nFieldLength = MIN(FieldSize,30)
nCaptionLength = LEN(cUsedName)
THIS.PARENT.grdGrid.COLUMNS(nFieldNum).WIDTH = MAX(nFieldLength,nCaptionLength) * nScaleMult
ENDSCAN