LOCAL lnCol, lcName WITH This *** Get the x co-ordinate of the rightmost position in the visible *** portion of the grid so if we have columns that are not visible *** we don't make the labels for their headers visible .nRight = .Left + .Width - IIF( .ScrollBars > 1, SYSMETRIC(5), 0 ) *** Loop through the grid's columns and create the labels to float *** on top of the headers FOR lnCol = 1 TO .ColumnCount lcName = "dHeader" + LTRIM( STR( lnCol ) ) This.Parent.Addobject(lcName, "Label") WITH EVAL("This.Parent." + lcName) *** Give the label the correct appearance .BackStyle = 0 && Transparent .BorderStyle = 0 && No Border .Alignment = 2 && Center alignment looks best .WordWrap = .T. .Caption = This.Columns[ lnCol ].Controls[ 1 ].Caption .FontName = This.Columns[ lnCol ].Controls[ 1 ].Fontname .FontSize = This.Columns[ lnCol ].Controls[ 1 ].FontSize .FontBold = This.Columns[ lnCol ].Controls[ 1 ].FontBold .Top = This.Top + This.nHdrMargin .Height = This.HeaderHeight - ( 2 * This.nHdrMargin ) This.Columns[ lnCol ].Controls[ 1 ].Caption = SPACE(0) ENDWITH ENDFOR *** Now set the left and width properties for the labels .RefreshHeaders() ENDWITHAnd this is what goes into RefreshHeaders:
LOCAL lnCol, lcName, lnHdrLeft, lnHdrWidth Thisform.LockScreen = .T. WITH This FOR lnCol = 1 TO .ColumnCount lcName = "dHeader" + LTRIM( STR( lnCol ) ) WITH EVAL("This.Parent." + lcName) lnHdrWidth = This.Columns[ lnCol ].Width - ( 2 * This.nHdrMargin ) .Width = IIF( lnHdrWidth > 0, lnHdrWidth, 0 ) *** Only set the left and visible properties if this column in visible lnHdrLeft = OBJTOCLIENT( This.Columns[ lnCol ].Controls[ 1 ], 2 ) *** If we are in a container, find out the offset from the form *** and adjust the left value IF UPPER( This.Parent.BaseClass ) # 'FORM' lnHdrLeft = lnHdrLeft - OBJTOCLIENT( This.Parent, 2 ) ENDIF IF lnHdrLeft > 0 .Left = lnHdrLeft + This.nHdrMargin .Visible = .T. *** make sure that the width doesn't overflow the visible *** portion of the grid IF .Left + .Width > This.nRight lnHdrWidth = This.nRight - .Left - ( 2 * This.nHdrMargin ) .Width = IIF( lnHdrWidth > 0, lnHdrWidth, 0 ) ENDIF ELSE .Visible = .F. ENDIF ENDWITH ENDFOR ENDWITH Thisform.LockScreen = .F.Like I said, it CAN be done, but it is expensive < s >.