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