本例效果图:

代码文件:


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;
    RadioButton1: TRadioButton;
    RadioButton2: TRadioButton;
    RadioButton3: TRadioButton;
    procedure FormCreate(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure RadioButton1Click(Sender: TObject);
    procedure RadioButton2Click(Sender: TObject);
    procedure RadioButton3Click(Sender: TObject);
  end; var
  Form1: TForm1; implementation {$R *.dfm} procedure TForm1.FormCreate(Sender: TObject);
begin
  ListView1.Align := alLeft;
  Button1.Caption := '添加';
  Button2.Caption := '清空';
  RadioButton1.Caption := 'ViewStyle = vsIcon';
  RadioButton2.Caption := 'ViewStyle = vsList';
  RadioButton3.Caption := 'ViewStyle = vsReport';
  RadioButton1.Checked := True;
end; procedure TForm1.Button1Click(Sender: TObject);
var
  item: TListItem;
begin
  item := ListView1.Items.Add;
  item.Caption := 'Item' + IntToStr(ListView1.Items.Count);
end; procedure TForm1.Button2Click(Sender: TObject);
begin
  ListView1.Clear;
end; procedure TForm1.RadioButton1Click(Sender: TObject);
begin
  ListView1.ViewStyle := vsIcon; {这是默认值}
end; procedure TForm1.RadioButton2Click(Sender: TObject);
begin
  ListView1.ViewStyle := vsList;
end; procedure TForm1.RadioButton3Click(Sender: TObject);
begin
  ListView1.ViewStyle := vsReport;
  if ListView1.Columns.Count = then ListView1.Columns.Add.Caption := '标题';
end; end.

窗体文件:


object Form1: TForm1
  Left =
  Top =
  Caption = 'Form1'
  ClientHeight =
  ClientWidth =
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -
  Font.Name = 'Tahoma'
  Font.Style = []
  OldCreateOrder = False
  OnCreate = FormCreate
  PixelsPerInch =
  TextHeight =
  object ListView1: TListView
    Left =
    Top =
    Width =
    Height =
    Columns = <>
    TabOrder =
  end
  object Button1: TButton
    Left =
    Top =
    Width =
    Height =
    Caption = 'Button1'
    TabOrder =
    OnClick = Button1Click
  end
  object Button2: TButton
    Left =
    Top =
    Width =
    Height =
    Caption = 'Button2'
    TabOrder =
    OnClick = Button2Click
  end
  object RadioButton1: TRadioButton
    Left =
    Top =
    Width =
    Height =
    Caption = 'RadioButton1'
    TabOrder =
    OnClick = RadioButton1Click
  end
  object RadioButton2: TRadioButton
    Left =
    Top =
    Width =
    Height =
    Caption = 'RadioButton2'
    TabOrder =
    OnClick = RadioButton2Click
  end
  object RadioButton3: TRadioButton
    Left =
    Top =
    Width =
    Height =
    Caption = 'RadioButton3'
    TabOrder =
    OnClick = RadioButton3Click
  end
end

 

最新文章

  1. 国内外前端(js)开发框架对比
  2. selenium 常见问题整理。
  3. Linux 配置nginx
  4. TYVJ1288 飘飘乎居士取能量块 -SilverN
  5. Jquery 将表单序列化为Json对象
  6. 表单form的属性,单行文本框、密码框、单选多选按钮
  7. gb2312编码提交url乱码解决
  8. ⑤JS返回格式化的当前时间和上周时间
  9. python并发编程之线程(一):线程&amp;守护线程&amp;全局解释器锁
  10. 01_学习java WEB涉及到的相关技术
  11. 解决input框自动填充为黄色的问题
  12. C# 中使用log4.net的注意事项
  13. Java json转model
  14. 解决element-ui upload组件报错 Avoid using non-primitive value as key, use string/number value instead
  15. 转载 【.NET基础】--委托、事件、线程(1) https://www.cnblogs.com/chengzish/p/4559268.html
  16. 实现Cookie集合
  17. Odoo中连接mysql数据库
  18. vue2.0 之标签属性
  19. extern字符串常量,宏定义字符串常量,怎么选
  20. 获取应用程序根目录物理路径(Web and Windows)

热门文章

  1. shell的命令格式
  2. fullPage.js全屏滚动插件API
  3. jQuery获取data-*属性值
  4. Hadoop(20)-MapReduce框架原理-OutputFormat
  5. hive 学习系列五(hive 和elasticsearch 的交互,很详细哦,我又来吹liubi了)
  6. py3.7.1下pyinstaller 的安装及打包 坑
  7. JAVA多进程入门
  8. 20145202 《网络对抗技术》 PC平台逆向破解
  9. 【Consul】Consul架构-Consensus协议
  10. 源码解析:解析掌阅X2C 框架