unit1.~pas

来自「不同夜色的listview列表框」· ~PAS 代码 · 共 52 行

~PAS
52
字号
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    ListBox1: TListBox;
    ListBox2: TListBox;
    procedure ListBox2DrawItem(Control: TWinControl; Index: Integer;
      Rect: TRect; State: TOwnerDrawState);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.ListBox2DrawItem(Control: TWinControl; Index: Integer;
  Rect: TRect; State: TOwnerDrawState);
begin
       with ListBox2.Canvas do
  begin
    FillRect(Rect);
    Font.Size := 20;
    if Index mod 2 =0 Then
    begin
      Font.Name := '宋体';
      Font.Color :=clBlue;//Clred;
    end
    else
    begin
      Font.Name := '隶书';
      Font.Color := Clgreen;
    end;
     TextOut(Rect.Left+1, Rect.Top+1,
     ListBox2.Items[Index]);
  end;

end;

end.

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?