Board index » delphi » Q: ListBox color

Q: ListBox color


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



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.}

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

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

  {paint the temporary bitmap here}

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

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

----------------------- Headers --------------------------------
Return-Path: <>
Received: from ( []) by (v39.9) with SMTP; Thu, 26 Feb 1998 16:53:04 1900
Received: from ( [])
          by (8.8.5/8.8.5/AOL-4.0.0)
          with ESMTP id QAA04849 for <>;
          Thu, 26 Feb 1998 16:53:01 -0500 (EST)
Received: from gateway.Advatel ([])
        by (8.8.5/8.8.5) with SMTP id JAA19119
        for <>; 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 <>
To: "''" <>
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

Re:Q: ListBox color

Gasolin wrote in message <>...
>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


Other Threads