Hi Kevin,

I just had a play. Try this....

Set 'style' prop to 'lbOwnerDrawFixed'.
Add some items (I used 3).
Add this code to the 'OnDrawItem' event handler:

procedure TForm1.ListBox1DrawItem(Control: TWinControl; Index: Integer;  Rect: TRect; 
State: TOwnerDrawState);
begin
  with listbox1.Canvas do begin
    if State = [] then begin
      if Index = 1 then begin {The second item is a special case so make it look 
different}
        Brush.Color := clRed;
        Font.Color := clWhite;
      end else begin {std item}
        Brush.Color := clWindow;
        Font.Color := clWindowText;
      end;
    end else if odSelected in State then begin {draw selected item differently}
      Brush.Color := clLime;
      Font.Color := clWhite;
    end;
    Brush.Style := bsSolid;
    FillRect(Rect);
    TextRect(Rect, Rect.Left+2, rect.Top+2, ListBox1.Items[Index]);
  end;
end;

HTH

Chris

> -----Original Message-----
> From: Kevin Parker [mailto:[EMAIL PROTECTED]]
> Sent: Monday, 23 September 2002 12:20 a.m.
> To: Multiple recipients of list delphi
> Subject: [DUG]: Highlighting text in a ListBox
> 
> 
> OK I give up.  How do you HighLight a line of text in a ListBox? 
> 
> Kevin
> 
> --------------------------------------------------------------
> -------------
>     New Zealand Delphi Users group - Delphi List - 
> [EMAIL PROTECTED]
>                   Website: http://www.delphi.org.nz
> To UnSub, send email to: [EMAIL PROTECTED] 
> with body of "unsubscribe delphi"
> Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/
> 
---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED]
with body of "unsubscribe delphi"
Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/

Reply via email to