I am trying to find a way to display special characters in a grids header. For example;
I have a method written in my grid class that when I click on a grid header, it sorts the grid accordingly. I also change the caption of the header to include an up arrow (^) when the header is first clicked and then a dash (-) when the header is clicked a second time.
It would be nice to be able to display something better than the the dash (-), like the down arrow [chr(24)]. Or better yet, append a nice icon.
Has anyone ever done this?
And if anyone is interested, here is the method I am using...
Greg Grewe
West Chester, Ohio
I have a method written in my grid class that when I click on a grid header, it sorts the grid accordingly. I also change the caption of the header to include an up arrow (^) when the header is first clicked and then a dash (-) when the header is clicked a second time.
It would be nice to be able to display something better than the the dash (-), like the down arrow [chr(24)]. Or better yet, append a nice icon.
Has anyone ever done this?
And if anyone is interested, here is the method I am using...
Code:
LOCAL lcSafety AS Character, lcField AS Character, lcString AS Character, ;
lcAlias AS Character, loColumn AS Object, nView_Out AS Integer, ;
nWhere_Out AS Integer, nRelRow_Out AS Integer, nRelCol_Out AS Integer, ;
nXCoord_In AS Integer, nYCoord_In AS Integer, lnBuffering, lcSortOrder AS Character, ;
i as Integer, loHeader AS Object
nXCoord_In = MCOL(WONTOP(),3)
nYCoord_In = MROW(WONTOP(),3)
STORE 0 TO nWhere_Out, nRelRow_Out, nRelCol_Out, nView_Out
IF THIS.GridHitTest(nXCoord_In, nYCoord_In, @nWhere_Out, @nRelRow_Out, @nRelCol_Out)
loColumn = "THIS.Column" + ALLTRIM(STR(nRelCol_Out)) &&& + ".Header1"
loColumn = EVALUATE(loColumn)
lcAlias = UPPER(THIS.RecordSource)
lcString = UPPER(loColumn.ControlSource)
lcField = STRTRAN(lcString, lcAlias + ".", "")
lcString = EVALUATE(lcString)
SELECT(lcAlias)
lnBuffering = CURSORGETPROP("Buffering", lcAlias)
IF CURSORSETPROP("Buffering", 3, lcAlias)
lcSafety = SET('SAFETY')
SET SAFETY OFF
*
DO CASE
CASE VARTYPE(lcString) = "C"
lcSortOrder = "INDEX ON ALLTRIM(" + lcField + ")"
CASE VARTYPE(lcString) = "N" OR VARTYPE(lcString) = "Y" OR VARTYPE(lcString) = "D" ;
OR VARTYPE(lcString) = "T" OR VARTYPE(lcString) = "L"
lcSortOrder = "INDEX ON " + lcField
CASE VARTYPE(lcString) = "Q" OR VARTYPE(lcString) = "G" OR VARTYPE(lcString) = "O" ;
OR VARTYPE(lcString) = "X" OR VARTYPE(lcString) = "U"
lcSortOrder = loColumn.Header1.Caption
ENDCASE
*
FOR i = 1 TO THIS.ColumnCount
IF i <> nRelCol_Out &&& Reset all Header Captions, except the Header that was clicked
loHeader = "THIS.Column" + ALLTRIM(STR(i))
loHeader = EVALUATE(loHeader)
IF "(" $ loHeader.Header1.Caption
loHeader.Header1.Caption = ALLTRIM(LEFT(loHeader.Header1.Caption, AT("(", loHeader.Header1.Caption)-2))
ENDIF
ENDIF
ENDFOR
*
DO CASE
CASE '-' $ loColumn.Header1.Caption &&& Descending, change to Ascending
loColumn.Header1.Caption = ALLTRIM(LEFT(loColumn.Header1.Caption, AT("(", loColumn.Header1.Caption)-2) + " (^)")
lcSortOrder = lcSortOrder + " TAG Key ASCENDING"
CASE '^' $ loColumn.Header1.Caption &&& Ascending, change to Descending
loColumn.Header1.Caption = ALLTRIM(LEFT(loColumn.Header1.Caption, AT("(", loColumn.Header1.Caption)-2) + " (-)")
lcSortOrder = lcSortOrder + " TAG Key DESCENDING"
OTHERWISE &&& Nothing Set, make Ascending
loColumn.Header1.Caption = ALLTRIM(loColumn.Header1.Caption) + " (^)"
lcSortOrder = lcSortOrder + " TAG Key ASCENDING"
ENDCASE
*
IF LEFT(lcSortOrder,5) = "INDEX"
&lcSortOrder
ELSE
=MESSAGEBOX('I am sorry, but I can not sorry this display by the field type "' + ;
ALLTRIM(lcSortOrder) + '", please select a different column!', 0, "Problem Sorting Display...")
ENDIF
GO TOP
SET SAFETY &lcSafety
=CURSORSETPROP("Buffering", lnBuffering, lcAlias)
ENDIF
THIS.Refresh
SELECT(THISFORM.rc_MasterAlias)
ELSE
ENDIF
Greg Grewe
West Chester, Ohio