Delphi TListView(TListBox+图标显示)

2021-07-08 16:08

阅读:441

标签:rap   graphic   winapi   interface   ctc   select   messages   image   div   

技术分享图片

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+图标显示)

标签:rap   graphic   winapi   interface   ctc   select   messages   image   div   

原文地址:https://www.cnblogs.com/YiShen/p/9733240.html


评论


亲,登录后才可以留言!