Что такое "по признаку, допустим bAlarm"?
А так, вот пример из drkb
Код:
procedure TForm1.ListBox1DrawItem(Control: TWinControl; Index: Integer;
Rect: TRect; State: TOwnerDrawState);
var
myBrush: TBrush;
begin
myBrush := TBrush.Create;
with (Control as TListBox) do
begin
if Items[index] = 'bAlarm' then
myBrush.Color := clRed else myBrush.Color := clWhite;
myBrush.Style := bsSolid;
Windows.FillRect(Canvas.Handle, Rect, myBrush.Handle);
Brush.Style := bsClear;
Canvas.TextOut(Rect.Left, Rect.Top, Items[Index]);
MyBrush.Free;
end;
end;
чтоб это заработало, выставите свойство Style как lbOwnerDrawFixed