加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

delphi listview使用

发布时间:2020-12-15 10:01:20 所属栏目:大数据 来源:网络整理
导读:unit Unit1; interface uses ? Windows,Messages,SysUtils,Variants,Classes,Graphics,Controls,Forms,? Dialogs,StdCtrls,ComCtrls; type ? TForm1 = class(TForm) ? ? ListView1: TListView; ? ? Button1: TButton; ? ? Button2: TButton; ? ? CheckBox1:

unit Unit1; interface uses ? Windows,Messages,SysUtils,Variants,Classes,Graphics,Controls,Forms,? Dialogs,StdCtrls,ComCtrls; type ? TForm1 = class(TForm) ? ? ListView1: TListView; ? ? Button1: TButton; ? ? Button2: TButton; ? ? CheckBox1: TCheckBox; ? ? CheckBox2: TCheckBox; ? ? procedure FormCreate(Sender: TObject); ? ? procedure Button1Click(Sender: TObject); ? ? procedure Button2Click(Sender: TObject); ? ? procedure CheckBox1Click(Sender: TObject); ? ? procedure CheckBox2Click(Sender: TObject); ? private ? ? { Private declarations } ? public ? ? { Public declarations } ? end; var ? Form1: TForm1; implementation {$R *.dfm} procedure TForm1.FormCreate(Sender: TObject); var i:Integer; ? ? column:TListColumn; begin ? for i := 0 to 5 do ? begin ? ? column := ListView1.Columns.Add; ? ? column.Caption := Format('Col %d',[i]); ? end; ? ListView1.Align := alTop; ? ListView1.ViewStyle := vsReport; ? ListView1.GridLines := True; ? ? ? ? {非默认} ? ListView1.ShowColumnHeaders := True; {默认} ? CheckBox1.Caption := 'GridLines'; ? CheckBox2.Caption := 'ShowColumnHeaders'; ? CheckBox1.Checked := True; ? CheckBox2.Checked := True; ? Button1.Caption := '添加'; ? Button2.Caption := '清空'; end; procedure TForm1.Button1Click(Sender: TObject); var item:TListItem; ? ? i:Integer; begin ? item := ListView1.Items.Add; ? ?//添加一行 ? item.Caption := 'Item ' + IntToStr(item.Index); ? for i := 0 to ListView1.Columns.Count - 1 do ? ? item.SubItems.Add(Format('%d%d',[item.Index,i])); end; procedure TForm1.Button2Click(Sender: TObject); begin ? ListView1.Items.Clear; end; procedure TForm1.CheckBox1Click(Sender: TObject); begin ? ListView1.GridLines:=CheckBox1.Checked; end; procedure TForm1.CheckBox2Click(Sender: TObject); begin ? ListView1.ShowColumnHeaders:=CheckBox2.Checked; end; end.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读