Recent

Author Topic: [Solved]StringGrid does not show HINT!?  (Read 1992 times)

TraumTaenzerDieter

  • New Member
  • *
  • Posts: 32
[Solved]StringGrid does not show HINT!?
« on: August 27, 2024, 12:20:31 pm »
I first thought it was my fault, but even the grid in
example\title_images does not show it's hint!
So, can anybody tell me what is going wrong here?

Lazarus 3.4
Windows 7+10
« Last Edit: August 28, 2024, 09:42:23 am by TraumTaenzerDieter »

Joanna

  • Hero Member
  • *****
  • Posts: 1072
Re: StringGrid does not show HINT!?
« Reply #1 on: August 27, 2024, 05:50:30 pm »
First thing to do is open up the grids unit line  or use autocomplete to find out what tstringgrid has regarding hints.

There are properties for onshowhint event and  showhint:boolean;
Have you tried setting showhint:= true;

Showing hint is an event that needs a procedure written for it.

I’m not sure if titles show hints.
« Last Edit: August 27, 2024, 05:53:11 pm by Joanna »
✨ 🙋🏻‍♀️ More Pascal enthusiasts are needed on IRC .. https://libera.chat/guides/ IRC.LIBERA.CHAT  Ports [6667 plaintext ] or [6697 secure] channel #fpc  #pascal Please private Message me if you have any questions or need assistance. 💁🏻‍♀️

TraumTaenzerDieter

  • New Member
  • *
  • Posts: 32
Re: StringGrid does not show HINT!?
« Reply #2 on: August 27, 2024, 06:56:06 pm »
Thanks for your reply Joanna.
The property ShowHint is set to True and in the
E:\Lazarus\examples\gridexamples\title_images
there also is no OnShowHint procedure for displaying the hint of the grid.
In additon, the TdbGrid (which derives from TstringGrid) displays the hints correctly,
so there must be something else going wrong.

Hansvb

  • Hero Member
  • *****
  • Posts: 701
Re: StringGrid does not show HINT!?
« Reply #3 on: August 27, 2024, 07:05:07 pm »
Try this:

Code: Pascal  [Select][+][-]
  1. unit Unit1;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8.   Classes, SysUtils, Forms, Controls, Graphics, Dialogs, Grids, StdCtrls;
  9.  
  10. type
  11.  
  12.   { TForm1 }
  13.  
  14.   TForm1 = class(TForm)
  15.     StringGrid1: TStringGrid;
  16.     procedure FormCreate(Sender: TObject);
  17.     procedure StringGrid1MouseMove(Sender: TObject; Shift: TShiftState; X,
  18.       Y: Integer);
  19.   private
  20.  
  21.   public
  22.  
  23.   end;
  24.  
  25. var
  26.   Form1: TForm1;
  27.  
  28. implementation
  29.  
  30. {$R *.lfm}
  31.  
  32. { TForm1 }
  33.  
  34. procedure TForm1.FormCreate(Sender: TObject);
  35. begin
  36.   // just some values...
  37.   StringGrid1.Cells[1,1] := 'Cell 1';
  38.   StringGrid1.Cells[2,1] := 'Cell 2';
  39.  
  40.   StringGrid1.Options:=StringGrid1.Options+[goCellHints]; // <<--- Important
  41.   StringGrid1.ShowHint:=True;
  42. end;
  43.  
  44. procedure TForm1.StringGrid1MouseMove(Sender: TObject; Shift: TShiftState; X,
  45.   Y: Integer);
  46. var
  47.   Row   : Integer;
  48.   Col   : Integer;
  49. begin
  50.   StringGrid1.MouseToCell(X, Y, Col, Row);
  51.  
  52.   if (Row >= 0) and (Col >= 0) and (StringGrid1.Hint <> StringGrid1.Cells[Col, Row]) then
  53.   begin
  54.     StringGrid1.Hint:= StringGrid1.Cells[Col,Row];
  55.   end;
  56. end;
  57.  
  58. end.  

wp

  • Hero Member
  • *****
  • Posts: 12354
Re: StringGrid does not show HINT!?
« Reply #4 on: August 27, 2024, 07:24:50 pm »
The title_images demo was written to show how images can be displayed in the title, not how hint texts can be displayed (Yes, StringGrid.ShowHint should be false with this intention in mind...).

These are the steps to show individual cell hints (not sure if you mean that...):
  • Make sure that StringGrid.ShowHint is true
  • Add the goCellHints option to the grid's Options; this activates the feature that each cell can have its own hint text.
  • Write a handler for the OnGetCellHint event; it must return the hint text for the cell at the specified column and row.
Code: Pascal  [Select][+][-]
  1. procedure TForm1.StringGrid1GetCellHint(Sender: TObject; ACol, ARow: Integer;
  2.   var HintText: String);
  3. begin
  4.   HintText := Format('Cell at column %d and row %d', [ACol, ARow]);
  5. end;

A special case are hints for long texts which do not fit into their cells. Here you must add the options goTruncCellHints and (usually) goCellEllipsis (instead of goCellHints). When you run the demo and decrease the width of the "Fruit" column so that it truncates the "Pineapple" text you'll see the cell ellipsis indicating that the text extends beyond the edge of the cell, and when you move the mouse over the "Pineapple" cell the full cell text is displayed in the popup.

You can even combine goCellHints with goTruncCellHints/goCellEllipsis - now you get the individual cell hint text together with a too-long cell text. Fine-tuning of which texts are displayed is possible to some degree by means of the CellHintPriority property.

Hints are explained in https://wiki.lazarus.freepascal.org/Grids_Reference_Page#Cell_hints.

« Last Edit: August 27, 2024, 07:27:16 pm by wp »

tetrastes

  • Hero Member
  • *****
  • Posts: 529
Re: StringGrid does not show HINT!?
« Reply #5 on: August 27, 2024, 08:29:59 pm »
Change TStringGrid property CellHintPriority from chpAllNoDefault to chpAll.

Joanna

  • Hero Member
  • *****
  • Posts: 1072
Re: StringGrid does not show HINT!?
« Reply #6 on: August 28, 2024, 05:51:43 am »
here is some sample code of how I used tstringgrid. i hope it helps
Code: Pascal  [Select][+][-]
  1. UNIT STRING_GRID_2021; // Created May 10, 2021 ancestor for all grids that take arrays of strings
  2.                        // loads arrays of strings into a grid and shows my color scheme
  3. {$mode objfpc}{$H+}
  4.  
  5. INTERFACE
  6.  
  7. USES
  8.   CLASSES, SYSUTILS, FILEUTIL, FORMS, CONTROLS, ExtCtrls, StdCtrls,
  9.   UTIL_2023, ENGLISH_STRINGS_2023, Buttons, ComCtrls, app_unit_2024, Graphics,
  10.   Grids, MY_POLYMORPH_2024,Dialogs,HELPERS_UNIT_2024;
  11.  
  12. TYPE
  13.  
  14.   { TFRAME_STRING_GRID_2021 }
  15.  
  16.   TFRAME_STRING_GRID_2021 = CLASS(TFrame_MY_POLYMORPH_2024)
  17.    GRID: TStringGrid;
  18.    PRIVATE  { private declarations }                                            // ♀ ♂ ♂
  19.   PUBLIC   { public declarations }
  20.     CONSTRUCTOR Create(THEOWNER:TComponent); OVERRIDE;
  21.     PROCEDURE ACTIVATE; OVERRIDE;
  22.     PROCEDURE CREATE_GRID (CONST NUM_COL,NUM_ROWS:Word); // when dimensions of grid are known and constant
  23.     PROCEDURE CREATE_SQUARE_GRID (CONST SIDE_LEN:Word); // makes a square grid
  24.     PROCEDURE CREATE_TITLES (CONST TITLES:TStringArray); // creates columns and adds titles titles and
  25.     PROCEDURE CREATE_LEFT_COLUMN (CONST ROW_TITLES:TStringArray); // the left side of the grid will be made fixed and added to
  26.  
  27.     PROCEDURE SIZE_PRIORITIES;
  28.     PROCEDURE DRAW_GRID_LINE (SENDER: TOBJECT; ACOL, AROW: INTEGER; ASTATE: TGRIDDRAWSTATE); VIRTUAL; // this an be overridden for descendants that want to blank out parts of the grid
  29.     PROCEDURE USE_PARENT_COLORS (SENDER: TOBJECT; ACOL, AROW: INTEGER; ASTATE: TGRIDDRAWSTATE);
  30.     PROCEDURE COLOR_CELL (CONST ACOLOR,TXT_COLOR:TColor ;SENDER: TOBJECT; ACOL, AROW: INTEGER; ASTATE: TGRIDDRAWSTATE); // for colors that dont work well with invert color
  31.     PROCEDURE COLOR_CELL (CONST ACOLOR:TColor;SENDER: TOBJECT; ACOL, AROW: INTEGER; ASTATE: TGRIDDRAWSTATE); // text is always white
  32.     PROCEDURE HIGHLIGHT (SENDER: TOBJECT; ACOL, AROW: INTEGER; ASTATE: TGRIDDRAWSTATE); VIRTUAL; // the default is to highlight by positive negative numbers
  33. {} PROCEDURE PREPARE_FIXED_CANVAS ( SENDER: TOBJECT;ACOL, AROW: INTEGER; ASTATE: TGRIDDRAWSTATE) ; //
  34.     PROCEDURE PREPARE_CANVAS( SENDER: TOBJECT; ACOL, AROW: INTEGER; ASTATE: TGRIDDRAWSTATE) ;
  35.     FUNCTION ROW_COUNT:Word; // used for adding things at the end by descendants
  36.     PROCEDURE ADD_ROW (CONST ROW_NUMBER:WORD; CONST STRINGS:TStringArray);
  37.     PROCEDURE RESIZE_FRAME;OVERRIDE;//( SENDER: TOBJECT) ; OVERRIDE;
  38.     PROCEDURE TEST; OVERRIDE;
  39.     PROTECTED { protected declarations }
  40.        PROCEDURE GET_HINT_COL_AND_ROW (SENDER: TOBJECT;HINTINFO: PHINTINFO); // set global variables once per hint event
  41.     FUNCTION TITLE_STRING ( SENDER: TOBJECT) : String; // called by cell screen when cell is a title row
  42.      FUNCTION CELL_STRING( SENDER: TOBJECT) : STRING; // get the value of the cell using global variables for hint_row and hint column
  43.      FUNCTION TITLE_TO_CELL_STRING (CONST SEPARATOR:ShortString ;SENDER:TObject):STRING; // for two dates scores and ephem grid
  44.      FUNCTION HINT_STRING (SENDER: TOBJECT) :String; VIRTUAL;  //{;HINTINFO: PHINTINFO} the actual string that is assigned to the hint
  45.        PROCEDURE SHOW_HINT(SENDER: TOBJECT; HINTINFO: PHINTINFO) ; //VIRTUAL;  // to make it easier to read default behaviors just shows what is in the grid cell
  46.      VAR
  47.      HINT_COL,HINT_ROW:INTEGER;
  48.   END;
  49.  
  50. IMPLEMENTATION
  51.  
  52. {$R *.lfm}
  53.  
  54. { TFRAME_STRING_GRID_2021 }
  55.  
  56. CONSTRUCTOR TFRAME_STRING_GRID_2021.CREATE( THEOWNER: TCOMPONENT) ;
  57.             VAR X:INTEGER;
  58.               O:TGridOption;
  59.               S:STRING;
  60. BEGIN
  61. INHERITED Create(THEOWNER);
  62. WITH GRID DO
  63.      BEGIN
  64.      ShowHint := True;
  65.      TitleFont:= Parent.Font;
  66.      DoubleBuffered := TRUE;
  67.      ScrollBars := ssNone;
  68.      FixedCols := 0;
  69.      FixedRows := 0;
  70.      ColCount := 1;
  71.      RowCount := 1;
  72.      AutoAdjustColumns ;
  73.     AutoSizeColumns;
  74.     ParentFont := True;
  75.     Options := options - [goRowHighlight,goSelectionActive,goRowSelect];
  76.     options:= Options +[goRowSizing];
  77.      END;
  78. END;
  79.  
  80.  PROCEDURE TFRAME_STRING_GRID_2021.ACTIVATE;
  81. BEGIN
  82.   INHERITED ACTIVATE;
  83. GRID.OnPrepareCanvas := @PREPARE_CANVAS;
  84.  GRID.OnShowHint := @SHOW_HINT;
  85. END;
  86.  
  87.  PROCEDURE TFRAME_STRING_GRID_2021.CREATE_GRID( CONST NUM_COL, NUM_ROWS: WORD) ;
  88.            VAR X:Integer;
  89.  BEGIN
  90.  WITH GRID,Columns DO
  91.       BEGIN
  92.       RowCount := NUM_ROWS;
  93.       FOR X:= Count TO NUM_COL DO
  94.           Add;
  95.       END;
  96.  END;
  97.  
  98.  PROCEDURE TFRAME_STRING_GRID_2021.CREATE_SQUARE_GRID( CONST SIDE_LEN: WORD) ;
  99.  BEGIN
  100.  CREATE_GRID(SIDE_LEN,SIDE_LEN);
  101.  END;
  102.  
  103.  PROCEDURE TFRAME_STRING_GRID_2021.CREATE_TITLES( CONST TITLES: TSTRINGARRAY) ;
  104.            VAR X:INTEGER;
  105.  BEGIN
  106.  WITH GRID DO
  107.       BEGIN
  108.       FixedRows := 1; // make sure there is a place to put titles they dont work for non fixed rows
  109.       WITH Columns DO
  110.            BEGIN
  111.            X:= Count;
  112.            X:= FixedCols + Length(TITLES);
  113.            IF Count <  Length(TITLES)
  114.               THEN FOR X:= 1 TO ( Length(TITLES))- Count DO
  115.                        Add;
  116.            FOR X:= 0 TO High(TITLES) DO
  117.                WITH Items[X] DO
  118.                     BEGIN
  119.                     Title.Alignment:= taCenter;   // everything centered
  120.                     Alignment:= taCenter;
  121.                    //test TitleFont.Color := Parent.FONT.Color;
  122.                     Title.Caption:= TITLES [X];
  123.                     END;
  124.            X:= Count ;
  125.            END;
  126.       END;
  127.  END;
  128.  
  129.  PROCEDURE TFRAME_STRING_GRID_2021.CREATE_LEFT_COLUMN( CONST ROW_TITLES: TSTRINGARRAY) ;
  130.            VAR X:INTEGER;
  131.              s:string;
  132.  BEGIN
  133.  WITH GRID DO
  134.       BEGIN
  135.       FixedCols := 1;
  136.       WITH Columns DO
  137.            BEGIN
  138.            IF Count = 0
  139.               THEN Add;  // the grid has minimum of one column but these arent the same
  140.            Items[0].Alignment := taCenter;
  141.            END;
  142.       IF FixedRows > 0
  143.          THEN Cells[0,0]:= '';
  144.       RowCount := LENGTH(ROW_TITLES)+1;
  145.      // Cells[0,0]:= ''; // clear the text
  146.       FOR X:= 0 TO High(ROW_TITLES) DO
  147.           begin
  148.           Cells[0,X + ORD (FixedRows)]:= ROW_TITLES [X];
  149.           s:= Cells[0,X + ORD (FixedRows)];
  150.           END;
  151.       END;
  152.  END;
  153.  
  154.  PROCEDURE TFRAME_STRING_GRID_2021.GET_HINT_COL_AND_ROW ( SENDER: TOBJECT; HINTINFO: PHINTINFO) ;
  155.  BEGIN
  156.  HINT_COL := -1;
  157.  HINT_ROW := -1;
  158.  WITH SENDER AS TStringGrid,HINTINFO^.CursorPos DO
  159.       MouseToCell(X, Y, HINT_COL, HINT_ROW);
  160.  END;
  161.  
  162.  FUNCTION TFRAME_STRING_GRID_2021.TITLE_STRING( SENDER: TOBJECT) : STRING;
  163.           VAR
  164.           EMPTY_CORNER:Boolean; // to shift things over only when corner is empty
  165.           OFFSET:ShortInt;
  166.  BEGIN
  167. WITH SENDER AS TStringGrid DO
  168.      BEGIN
  169.      EMPTY_CORNER := ((FixedCols =1)AND(FixedRows =1));
  170.      IF EMPTY_CORNER AND (HINT_COL = 0) THEN EXIT ('');  //its in the empty corner
  171.      OFFSET:= ORD (EMPTY_CORNER AND (HINT_COL > 0)); // when there is an empty corner offset by -1 for titles not in corner
  172.      RESULT:= Columns.Items[HINT_COL - OFFSET].Title.Caption  //title caption
  173.      END;
  174.  END;
  175.  
  176.  FUNCTION TFRAME_STRING_GRID_2021.CELL_STRING( SENDER: TOBJECT) : STRING;
  177. BEGIN
  178. WITH SENDER AS TStringGrid DO
  179.      IF (FixedRows = 1) AND (HINT_ROW = 0)
  180.         THEN Exit (TITLE_STRING(SENDER)) // title rows are treated differently because they can have an empty corner that is nil apparently
  181.         ELSE RESULT:= Cells[HINT_Col,HINT_Row];       //cell text
  182. END;
  183.  
  184. FUNCTION TFRAME_STRING_GRID_2021.TITLE_TO_CELL_STRING( CONST SEPARATOR: SHORTSTRING; SENDER: TOBJECT) : STRING;
  185.         //CONST AR_SYM:ARRAY[BOOLEAN] OF ShortString  = (' -> ','');
  186. BEGIN
  187. WITH SENDER AS TStringGrid DO
  188.    IF (HINT_ROW = 0) AND (GRID.FixedRows = 1)
  189.        THEN Exit (TITLE_STRING(SENDER)) // call the ancestor method to show contents of title row cell
  190.        ELSE IF (HINT_COL = 0) AND (FixedCols = 1) //its in fixed left column
  191.                THEN RESULT:= CELL_STRING(SENDER)
  192.                ELSE RESULT:= TITLE_STRING(SENDER) + SEPARATOR + CELL_STRING(SENDER);
  193.         // RESULT:= TITLE_STRING(SENDER) + AR_SYM[(HINT_COL = 0) AND (FixedCols = 1)]+CELL_STRING(SENDER);
  194. END;
  195.  
  196.   FUNCTION TFRAME_STRING_GRID_2021.HINT_STRING( SENDER: TOBJECT) : STRING;
  197.  BEGIN
  198.  RESULT:= CELL_STRING(SENDER);  // get the info in the cell defined by global hint_col and hint_row variables
  199.  //RESULT:= CELL_STRING(SENDER,HINTINFO);  // for descendants other things can be added to cell string to make a report
  200.  END;
  201.  
  202. PROCEDURE TFRAME_STRING_GRID_2021.SHOW_HINT( SENDER: TOBJECT; HINTINFO: PHINTINFO) ;
  203. BEGIN
  204. GET_HINT_COL_AND_ROW(SENDER, HINTINFO);  // hint_col and hint_row are variables that tell where the cell is
  205. WITH SENDER AS TStringGrid,HINTINFO^ DO
  206.      BEGIN
  207.      HintStr := HINT_STRING(SENDER );
  208.      HintWindowClass := MY_HINT;
  209.      HintColor := APP.MY_FONT.Color;  // make hint stand out more
  210.      END;
  211. END;
  212.  
  213.  PROCEDURE TFRAME_STRING_GRID_2021.SIZE_PRIORITIES;
  214.            VAR X:Integer;
  215.  BEGIN
  216.  WITH GRID.Columns DO
  217.      FOR X:= 0 TO VisibleCount-1 DO
  218.          WITH Items[X] DO
  219.               SizePriority := ORD (X <> 0);
  220.  END;
  221.  
  222.  PROCEDURE TFRAME_STRING_GRID_2021.DRAW_GRID_LINE( SENDER: TOBJECT; ACOL, AROW: INTEGER; ASTATE: TGRIDDRAWSTATE) ;
  223.  BEGIN
  224.  WITH SENDER AS TStringGrid DO
  225.       GridLineColor := canvas.Font.Color; // default behavior
  226.  END;
  227.  
  228.  PROCEDURE TFRAME_STRING_GRID_2021.USE_PARENT_COLORS ( SENDER: TOBJECT; ACOL, AROW: INTEGER; ASTATE: TGRIDDRAWSTATE) ;
  229.  BEGIN
  230.  WITH TStringGrid(SENDER),Canvas DO
  231.       BEGIN
  232.       Brush.Color:= Parent.Color;
  233.       Font.Color:= Parent.Font.Color;
  234.       DRAW_GRID_LINE(SENDER, ACOL, AROW, ASTATE);
  235.       //GridLineColor := Font.Color;// TitleFont.Color;//  clBlue;    //Font.Color ;
  236.       END;
  237.  END;
  238.  
  239.  PROCEDURE TFRAME_STRING_GRID_2021.COLOR_CELL( CONST ACOLOR, TXT_COLOR: TCOLOR; SENDER: TOBJECT; ACOL, AROW: INTEGER; ASTATE: TGRIDDRAWSTATE ) ;
  240.  BEGIN
  241.  WITH TStringGrid(SENDER).CANVAS  DO
  242.       BEGIN
  243.       Font.Color := TXT_COLOR;
  244.       Brush.Color := ACOLOR;
  245.       END;
  246.  END;
  247.            // use this one more for highlighting because user color preferences will vary
  248. PROCEDURE TFRAME_STRING_GRID_2021.COLOR_CELL( CONST ACOLOR: TCOLOR; SENDER: TOBJECT; ACOL, AROW: INTEGER; ASTATE: TGRIDDRAWSTATE) ;
  249.  BEGIN
  250.  COLOR_CELL(ACOLOR,InvertColor(ACOLOR),SENDER, ACOL, AROW, ASTATE);
  251.  END;
  252.             // redo this to use app unit GRID_HILITE_COLOR
  253.  PROCEDURE TFRAME_STRING_GRID_2021.HIGHLIGHT( SENDER: TOBJECT; ACOL, AROW: INTEGER; ASTATE: TGRIDDRAWSTATE) ;
  254.            FUNCTION CELL_VALUE:Integer;
  255.                     VAR REAL_VAL:Real;
  256.            BEGIN
  257.            REAL_VAL:= 0;
  258.            WITH SENDER AS TStringGrid,Canvas DO
  259.                  IF (NOT TryStrToInt(Cells[ACOL,AROW],Result) AND NOT TryStrToFloat(Cells[ACOL,AROW],REAL_VAL)) AND ((TRUNC(REAL_VAL) = 0) AND (Result = 0))
  260.                      THEN RESULT:= 0
  261.                      ELSE IF Result = 0
  262.                              THEN Result := trunc(REAL_VAL); // the cell value was a real number
  263.            END;
  264.            VAR CELL_VAL:Integer;
  265.  BEGIN
  266.  WITH SENDER AS TStringGrid,Canvas DO
  267.       BEGIN  // redo to use method in app unit to get color
  268.       CELL_VAL := CELL_VALUE;
  269.       IF APP.NEEDS_TO_HILITE(CELL_VAL)  // CELL_VAL = 0
  270.          THEN COLOR_CELL(APP.GRID_HILITE_COLOR(CELL_VAL),SENDER,ACOL,AROW,ASTATE)
  271.          ELSE USE_PARENT_COLORS(SENDER,ACOL,AROW,ASTATE); // string grid will be black if i dont do this
  272.        END;
  273.  END;
  274.  
  275.                                     // for fixed rows and columns
  276. PROCEDURE TFRAME_STRING_GRID_2021.PREPARE_FIXED_CANVAS  ( SENDER: TOBJECT; ACOL, AROW: INTEGER; ASTATE: TGRIDDRAWSTATE) ;
  277.             VAR
  278.             BRUSH_COLOR,FONT_COLOR:TCOLOR;
  279.             S:STRING;
  280.  BEGIN
  281.  WITH TStringGrid(SENDER) DO
  282.       BEGIN
  283.       IF (AROW = 0)
  284.          THEN BEGIN
  285.               s:= Font.Name;
  286.               IF ACOL= 0  // to reduce number of times this is done
  287.                  THEN RowHeights[0]:= STRING_HEIGHT('♆♅ ',TitleFont,Canvas)+ 5;//+2;
  288.               TitleFont.Name := Parent.Font.Name;   // for some reason the font was still default
  289.               s:= TitleFont.Name;
  290.               TitleFont.Color := Parent.Color; //InvertColor(Parent.Color); // text of titles
  291.               TitleFont.Bold:= TRUE;
  292.               FixedColor := Parent.font.Color; //test
  293.               END
  294.          ELSE BEGIN  // it is the left fixed column
  295.               Font.Bold:= TRUE;
  296.               Font:= TitleFont;
  297.               Font.Color := Parent.Color;
  298.               IF ACOL = 0
  299.                  THEN Font.Bold:= TRUE;
  300.                RowHeights[AROW]:=STRING_HEIGHT('♆♅ ',TitleFont,Canvas)+ 5 ;
  301.               END;
  302.      END;
  303.  END;
  304.            // redo this to use the new function in app unit for grid color
  305.  PROCEDURE TFRAME_STRING_GRID_2021.PREPARE_CANVAS( SENDER: TOBJECT; ACOL, AROW: INTEGER; ASTATE: TGRIDDRAWSTATE) ; // fixed rows stay the system color when i dont use this
  306.  BEGIN
  307.  WITH TStringGrid(SENDER) DO                   //,ACOL, AROW
  308.      IF{ APP.CONTRASTING_CONTROLS AND} (((AROW = 0) AND (FixedRows > 0)) OR ((ACOL = 0) AND (FixedCols > 0)))
  309.         THEN PREPARE_FIXED_CANVAS(SENDER,ACOL,AROW,ASTATE) // this makes contrast in fixed rows and columns
  310.         ELSE IF APP.HIGHLIGHT_CELLS AND (Cells[ACOL,AROW] <> '') AND (Cells[ACOL,AROW] <> '0')
  311.                 THEN HIGHLIGHT(SENDER,ACOL,AROW,ASTATE)
  312.                 ELSE USE_PARENT_COLORS(SENDER,ACOL,AROW,ASTATE)
  313. END;
  314.  
  315.  FUNCTION TFRAME_STRING_GRID_2021.ROW_COUNT: WORD;
  316.  BEGIN
  317.    RESULT:= GRID.RowCount;
  318.  END;
  319.  
  320. PROCEDURE TFRAME_STRING_GRID_2021.ADD_ROW( CONST ROW_NUMBER: WORD; CONST STRINGS: TSTRINGARRAY) ;
  321.             var X:integer;
  322.  BEGIN
  323.  WITH GRID DO
  324.       BEGIN
  325.       WITH Columns DO
  326.            FOR X:= Count TO HIGH(STRINGS) DO
  327.                BEGIN
  328.                Add;
  329.                Columns[X].Alignment := taCenter;
  330.                END;
  331.       IF RowCount < ROW_NUMBER + 1
  332.          THEN RowCount := ROW_NUMBER + 1;
  333.       FOR X:= 0 TO HIGH(STRINGS) DO
  334.           Cells[X + Ord(FixedCols = 1),ROW_NUMBER]:= STRINGS [X];
  335.       IF goFixedRowNumbering IN Options // make sure that this option is turned off for things that dont need this
  336.          THEN cells [0,ROW_NUMBER]:= ROW_NUMBER.ToString;
  337.       END;
  338.  END;
  339.  
  340.  PROCEDURE TFRAME_STRING_GRID_2021.RESIZE_FRAME;
  341.           VAR
  342.           X:INTEGER;
  343.           RH:WORD; // row heights total
  344. BEGIN
  345. GRID.TitleFont.Bold:= true;  ///test
  346. WITH GRID DO
  347.      BEGIN
  348.      Color:= clRed;
  349.      //AutoSizingAll;
  350.      TitleFont.Size:= SELF.Font.Size;
  351.      Font.Size :=  SELF.Font.Size;
  352.      AutoAdjustColumns ; // too short when i dont use this
  353.     AutoSizeColumns;
  354.       Columns.Items[0].Alignment := taCenter;
  355.     rh:= GridLineWidth *1;        // if i dont do this it loses bottom line
  356.      FOR X:= 0 TO RowCount-1  DO
  357.          INC (RH,RowHeights[X] );
  358.      CONSTRAIN_HT(RH);
  359.     //old CONSTRAIN_HEIGHT(RH);
  360.      END;
  361. END;
  362.  
  363.  PROCEDURE TFRAME_STRING_GRID_2021.TEST;
  364.            const
  365.   AR_LEFT_COL :ARRAY [0..2] OF String = ('1','2','3');
  366.          // AR_LEFT_COL :ARRAY [0..7] OF String = ('one','two','three','four','five','six','seven','eight');
  367.            AR_DATA:ARRAY [0..11] OF STRING = ('0','-1','10','A','?','-5','blank','-2.0','-23.9','5.6','9.7','1');
  368.          //AR_DATA:ARRAY [0..11] OF String = ('1984-2-22','8781 GE','2 TA','3 ar','4 aq','5 ge','6 vi','3 ar','3 ar','3 ar','3 ar','3 ar');
  369.            var x:Integer;
  370. BEGIN
  371. APP.CONTRASTING_CONTROLS := FALSE;
  372. GRID.FixedRows := 1;
  373. GRID.FixedCols := 1;
  374. CREATE_TITLES(AR_Data);
  375. //HIGLIGHT_THE_CELLS := TRUE;
  376. app.UPDATE_ALL_FORMS;
  377. //EXIT;
  378. for x:= 1 to 1 do
  379.     ADD_ROW(x,AR_DATA);
  380. END;
  381.  
  382. END.  
« Last Edit: August 28, 2024, 08:56:07 am by Joanna »
✨ 🙋🏻‍♀️ More Pascal enthusiasts are needed on IRC .. https://libera.chat/guides/ IRC.LIBERA.CHAT  Ports [6667 plaintext ] or [6697 secure] channel #fpc  #pascal Please private Message me if you have any questions or need assistance. 💁🏻‍♀️

TraumTaenzerDieter

  • New Member
  • *
  • Posts: 32
Re: StringGrid does not show HINT!?
« Reply #7 on: August 28, 2024, 07:43:49 am »
Thanks for all the replies, but I do NOT want to show CellHints,
I just want show the text of the property "HINT" when the mouse is over the grid!

TraumTaenzerDieter

  • New Member
  • *
  • Posts: 32
Re: StringGrid does not show HINT!?
« Reply #8 on: August 28, 2024, 08:08:41 am »
@tetrastes
THAT was the change that did it!!!
Thank you VERY MUCH !!

 

TinyPortal © 2005-2018