Recent

Author Topic: Problem with cell comment  (Read 568 times)

kjteng

  • Sr. Member
  • ****
  • Posts: 263
Problem with cell comment
« on: January 15, 2025, 02:17:57 pm »
I have problem with the following code:- the hint string (tx) is saved properly and can be displayed with showmessage(tx). However it is truncated (only show 'abc' ) when the hint is displayed (on mouse over the particular cell) :-
    ws.WriteComment(0, 1, 'abc | 12345');
    tx := ws.ReadComment(0, 1);
    showmessage(tx);     

How can I solve this ?  TQ in advance

wp

  • Hero Member
  • *****
  • Posts: 12597
Re: Problem with cell comment
« Reply #1 on: January 16, 2025, 02:40:51 pm »
The pipe character '|' has a special meaning in the LCL - it splits the popup hint text into two parts, a "short" part for the popup and a "long" part for the status bar. Since the worksheet grid displays the comment via the Hint property, it is affected by this feature. It can be avoided when the '|' is replaced by a unicode character looking similarly:

In unit fpspreadsheetgrid, function TsCustomWorksheetGrid.GetCellHintText(...), add the following code:
Code: Pascal  [Select][+][-]
  1.   [...]
  2.   // Read comment
  3.   comment := Worksheet.ReadComment(cell);
  4.  
  5.   if pos('|', comment) > 0 then                                             // <--- ADD
  6.     comment := StringReplace(comment, '|', #$E2#$94#$82, [rfReplaceAll]);   // <--- ADD
  7.  
  8.   // Read hyperlink info
  9.   if Worksheet.HasHyperlink(cell) then begin
  10.   [...]
  11.  

Or use the svn version of fpspreadsheet which was fixed in r9591.

kjteng

  • Sr. Member
  • ****
  • Posts: 263
Re: Problem with cell comment
« Reply #2 on: January 17, 2025, 04:37:08 am »
thank you very much Master.

 

TinyPortal © 2005-2018