5th
Июл

Изменение цвета шрифта надписи в ListBox

Posted by Chas under Пост-обзор

Stilet:

Вполне.
Выставь свойство Style:=lbOwnerDrawFixed
И опиши два обработчика:

procedure TForm1.ListBox1DrawItem(Control: TWinControl; Index: Integer;
Rect: TRect; State: TOwnerDrawState);
begin
   with TListBox(Control) do begin
     if index=ItemIndex then
     Canvas.font.Color:=clred
     else
       Canvas.font.Color:=clblack;
     Canvas.FillRect(rect);
     Canvas.TextOut(rect.Left,rect.Top,items[index]);
   end;
end;

procedure TForm1.ListBox1Click(Sender: TObject);
begin
   ListBox1.Repaint;
end;

Тема на форуме

Похожие статьи

Теги: | |