1. 程式人生 > >Delphi TListView(TListBox+圖標顯示)

Delphi TListView(TListBox+圖標顯示)

with sage windows implement ssa cap add nts graphic

技術分享圖片

unit Unit1;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes,
  Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, System.ImageList, Vcl.ImgList,
  Vcl.StdCtrls, Vcl.ComCtrls;

type
  TForm1 = class(TForm)
    lv1: TListView;
    添加: TButton;
    il1: TImageList;
    btn刪除選中: TButton;
    清空: TButton;
    btnDelete_select: TButton;
    
procedure 添加Click(Sender: TObject); procedure btn刪除選中Click(Sender: TObject); procedure btnDelete_selectClick(Sender: TObject); procedure 清空Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.dfm
} procedure TForm1.添加Click(Sender: TObject); begin if lv1.Columns.Count = 0 then lv1.Columns.Add.Caption := 111; lv1.Column[0].width := 200; with lv1.Items.Add do begin StateIndex := 2; Caption := Item + IntToStr(lv1.Items.Count); end; end; procedure TForm1.清空Click(Sender: TObject);
begin lv1.Clear; end; procedure TForm1.btnDelete_selectClick(Sender: TObject); begin lv1.Items[1].Delete; end; procedure TForm1.btn刪除選中Click(Sender: TObject); begin lv1.Selected.Delete; end; end.

Delphi TListView(TListBox+圖標顯示)