Recent

Author Topic: Color Items in listbox  (Read 4586 times)

BenJones

  • Full Member
  • ***
  • Posts: 121
Color Items in listbox
« on: July 01, 2011, 09:40:59 pm »
hi guys
I am new to lazarus been using it over a month or so now and very much likeing it, and made a few little things, My main project has been a windows Hosts editor. Now I have this idea I like to do but I duno were to start or even if it can be done.

anyway my program loads the windows host file contents in to a listbox. the host files contains comments, some blank lines and hosts example below:

# This is a test host file

127.0.0.1 localhost

Ok what I like to do if possiable is color the line items text comments # with orange and the rest of the file in black
is this possiable thanks.
« Last Edit: July 01, 2011, 09:42:38 pm by BenJones »
When Your Dreams Come True.

Ocye

  • Hero Member
  • *****
  • Posts: 518
    • Scrabble3D
Re: Color Items in listbox
« Reply #1 on: July 05, 2011, 11:43:31 am »
If you change the style of your TListBox to lbOwnerDraw* the OnDrawItem event can be used for that purpose. All canvas operations are available including Brush.Color, Rectangle(), or whatever you like.
Lazarus 1.7 (SVN) FPC 3.0.0

BenJones

  • Full Member
  • ***
  • Posts: 121
Re: Color Items in listbox
« Reply #2 on: July 05, 2011, 12:10:58 pm »
Thanks I give that a try
When Your Dreams Come True.

 

TinyPortal © 2005-2018