Board index » delphi » Q: ListBox color

Q: ListBox color

Hello

Can I have lines in different color in one listbox ??

Alan

 

Re:Q: ListBox color


someone suggested this to me:

try this

procedure TQueueEntryForm.GridDrawCell(Sender: TObject; Col,
  Row: Longint; Rect: TRect; State: TGridDrawState);

{paint the current cell in the current stringgrid.  Do it by painting a }
{temporary bitmap, and then COPYRECTing it over to the cell.}

var
  TempMap : TBitMap;
  Temprect : TRect;
begin
  Tempmap := tbitmap.create;
  TempMap.height := (sender as TStringgrid).RowHeights[Col];
  TempMap.width  := (sender as TStringgrid).ColWidths[Col];

  TempRect.left   := 1;
  TempRect.right  := TempMap.width;
  TempRect.top    := 1;
  TempRect.bottom := TempMap.height;

  {paint the temporary bitmap here}

  (sender as TStringgrid).canvas.copyrect(rect,Tempmap.canvas,Temprect);
  tempmap.free;
end;

works like a charm.  Okay, it's cheating, but I couldn't think of any other
way.

----------------------- Headers --------------------------------
Return-Path: <jk...@advatel.com.au>
Received: from  relay18.mail.aol.com (relay18.mail.aol.com [172.31.109.18]) by
air03.mail.aol.com (v39.9) with SMTP; Thu, 26 Feb 1998 16:53:04 1900
Received: from gateway.advatel.com.au (gateway.advatel.com.au [203.24.16.46])
          by relay18.mail.aol.com (8.8.5/8.8.5/AOL-4.0.0)
          with ESMTP id QAA04849 for <AmanU1...@aol.com>;
          Thu, 26 Feb 1998 16:53:01 -0500 (EST)
Received: from gateway.Advatel ([10.0.0.14])
        by gateway.advatel.com.au (8.8.5/8.8.5) with SMTP id JAA19119
        for <AmanU1...@aol.com>; Fri, 27 Feb 1998 09:16:48 +1100 (EST)
Received: by gateway.Advatel with Microsoft Mail
        id <01BD435D.2BA38...@gateway.Advatel>; Fri, 27 Feb 1998 08:53:27 +-1100
Message-ID: <01BD435D.2BA38C40@gateway.Advatel>
From: jason king <jk...@advatel.com.au>
To: "'AmanU1...@aol.com'" <AmanU1...@aol.com>
Subject: stringgrid
Date: Fri, 27 Feb 1998 08:53:21 +-1100
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit

AmanU1...@aol.com

Re:Q: ListBox color


Quote
Gasolin wrote in message <3545746b.40848...@news.image.dk>...
>Can I have lines in different color in one listbox ??

Sure, a Tlistbox has the property style which could be set to
lbOwnerDrawFixed, that is you have to draw the items yourself. You get a
OnDrawItem event whenever you have to draw an item. For more informatie have
a look at the TCustomListBox.Style entry in the delphi help file

Arjan

Other Threads