Recent

Author Topic: Which component for highlighting part of item/string  (Read 4451 times)

user2126296

  • Newbie
  • Posts: 6
Which component for highlighting part of item/string
« on: March 20, 2013, 01:12:27 pm »
Which component (TListView, TStringGrid, ...) do you recommend for this:
  • presentation of list items
  • items will be strings
  • specified substrings (e.g. words) will be highlighted - I need to highlight some words in a string/item.
Example: http://www.codeproject.com/Articles/103259/Highlight-Searched-Text-in-WPF-ListView

I am not aware of a way to change background color for a part of string (using OnCustomDrawItem).

Blaazen

  • Hero Member
  • *****
  • Posts: 3241
  • POKE 54296,15
    • Eye-Candy Controls
Re: Which component for highlighting part of item/string
« Reply #1 on: March 20, 2013, 01:56:40 pm »
TSynEdit (or TSynMemo)
Lazarus 2.3.0 (rev main-2_3-2863...) FPC 3.3.1 x86_64-linux-qt Chakra, Qt 4.8.7/5.13.2, Plasma 5.17.3
Lazarus 1.8.2 r57369 FPC 3.0.4 i386-win32-win32/win64 Wine 3.21

Try Eye-Candy Controls: https://sourceforge.net/projects/eccontrols/files/

user2126296

  • Newbie
  • Posts: 6
Re: Which component for highlighting part of item/string
« Reply #2 on: March 20, 2013, 03:05:48 pm »
TSynEdit (or TSynMemo)
It'd be non-standard usage of TSynMemo because of need to present tabular data:
  • read only row (can be easily implemented in TSynMemo)
  • when onclick on row, full row should be selected (not sure)
  • need to access data/strings in particular column







Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 11338
  • Debugger - SynEdit - and more
    • wiki
Re: Which component for highlighting part of item/string
« Reply #3 on: March 20, 2013, 04:04:25 pm »
The other option is to do painting yourself. Many components have on Paint, or even OnPaintItem (sorry no example)

theo

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1932
Re: Which component for highlighting part of item/string
« Reply #4 on: March 20, 2013, 05:23:25 pm »
Yes, paint it yourself.

Canvas.TextExtent   
Canvas.FillRect
Canvas.TextOut or TextRect

are your friends.

user2126296

  • Newbie
  • Posts: 6
Re: Which component for highlighting part of item/string
« Reply #5 on: March 20, 2013, 06:22:18 pm »
And which event should be the trigger to do the painting?
TListBox, TListView and TStringGrid have only OnDrawItem, no OnPaint(Item) event available. I do not know the difference between OnPaint(Item) and OnDrawItem events.

theo

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1932
Re: Which component for highlighting part of item/string
« Reply #6 on: March 21, 2013, 09:16:47 am »
Yes, OnDrawItem, OnCustomDraw ... etc. whatever seems appropriate.

 

TinyPortal © 2005-2018