Recent

Author Topic: TListView draw Item caption in bold  (Read 874 times)

bubulemaster

  • New Member
  • *
  • Posts: 47
TListView draw Item caption in bold
« on: September 17, 2021, 06:10:50 pm »
Hi all,

Sorry for my question, I'm not using Lazarus since many years.

I would like draw only the caption in bold.

For that, I use OnAdvancedCustomDrawItem :
Code: Pascal  [Select][+][-]
  1. procedure xxxxx.xxxxxAdvancedCustomDrawItem(
  2.   Sender: TCustomListView; Item: TListItem; State: TCustomDrawState;
  3.   Stage: TCustomDrawStage; var DefaultDraw: Boolean);
  4. begin
  5.   // NotWorking
  6.   Sender.Canvas.Font.Style := [fsBold];
  7.  
  8.   // Working
  9.   Sender.Canvas.Font.Color := clRed;
  10. end;
  11.  

For change color, it's working (Under Windows 10, Lazarus 2.0.13).

Is-it because DefaultDraw is set to true?

wp

  • Hero Member
  • *****
  • Posts: 11855
Re: TListView draw Item caption in bold
« Reply #1 on: September 17, 2021, 06:44:47 pm »
No luck, this is an old bug (https://gitlab.com/freepascal.org/lazarus/lazarus/-/issues/25397) which has not yet been solved. (There seemed to be a solution but it turned out that it had sideeffects).

When you absolutely need the bold caption you should switch to a StringGrid in which you can control text attributes in the OnPrepareCanvas event. And this works, guaranteed!

 

TinyPortal © 2005-2018