Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2004.11.14;
Скачать: CL | DM;

Вниз

Как изменить шрифт у нескольких записей в ListBox ?   Найти похожие ветки 

 
Max Ivanych ©   (2004-10-28 14:10) [0]

Заранее спасибо за ответ!


 
antonn ©   (2004-10-28 14:17) [1]

Использовать OnDrawItems. Смотри, где-то рядом было..


 
ssk ©   (2004-10-28 14:43) [2]

Вот пример.

procedure TForm1.ListBox1DrawItem(Control: TWinControl; Index: Integer;
 Rect: TRect; State: TOwnerDrawState);
var
 s: string;
begin
 with ListBox1 do
   begin
     s := Items[Index];
     Canvas.FillRect(Rect);
     case Index of
       0: begin
            Canvas.Font.Name := "Tahoma";
            Canvas.Font.Style := [fsBold];
          end;
       1: begin
            Canvas.Font.Name := "Tahoma";
            Canvas.Font.Style := [fsItalic];
          end;
     end;
     Canvas.TextOut(0, Rect.Top, s);
   end;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
 ListBox1.Style := lbOwnerDrawFixed;
 ListBox1.Clear;
 ListBox1.Items.Add("Первая строка");
 ListBox1.Items.Add("Вторая строка");
end;


 
Max Ivanych ©   (2004-10-28 14:52) [3]

ssk ©
Спасибо!


 
ssk ©   (2004-10-28 15:21) [4]

Вот пример.

procedure TForm1.ListBox1DrawItem(Control: TWinControl; Index: Integer;
 Rect: TRect; State: TOwnerDrawState);
var
 s: string;
begin
 with ListBox1 do
   begin
     s := Items[Index];
     Canvas.FillRect(Rect);
     case Index of
       0: begin
            Canvas.Font.Name := "Tahoma";
            Canvas.Font.Style := [fsBold];
          end;
       1: begin
            Canvas.Font.Name := "Tahoma";
            Canvas.Font.Style := [fsItalic];
          end;
     end;
     Canvas.TextOut(0, Rect.Top, s);
   end;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
 ListBox1.Style := lbOwnerDrawFixed;
 ListBox1.Clear;
 ListBox1.Items.Add("Первая строка");
 ListBox1.Items.Add("Вторая строка");
end;



Страницы: 1 вся ветка

Текущий архив: 2004.11.14;
Скачать: CL | DM;

Наверх




Память: 0.47 MB
Время: 0.032 c
1-1098940211
Font
2004-10-28 09:10
2004.11.14
Unicode и VCL


1-1099386557
Yurij-7
2004-11-02 12:09
2004.11.14
ComboBox


9-1088251752
Proger
2004-06-26 16:09
2004.11.14
Работа с памятью


3-1098079804
goldenmax
2004-10-18 10:10
2004.11.14
Как скопировать таблицу DBF в IB.


14-1098196845
able
2004-10-19 18:40
2004.11.14
avi2scr & scr поставить, как стандартный ScreenSaver