本例效果图:


代码文件:


unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ComCtrls; type
  TForm1 = class(TForm)
    ListView1: TListView;
    Button1: TButton;
    CheckBox1: TCheckBox;
    procedure FormCreate(Sender: TObject);
    procedure ListView1Change(Sender: TObject; Item: TListItem;
      Change: TItemChange);
    procedure CheckBox1Click(Sender: TObject);
    procedure Button1Click(Sender: TObject);
  end; var
  Form1: TForm1; implementation {$R *.dfm} procedure TForm1.FormCreate(Sender: TObject);
const
  ps: array[.., ..] of string = (
    ('赵', '男', '88'),
    ('钱', '男', '77'),
    ('孙', '女', '66'),
    ('李', '男', '55'),
    ('周', '女', '44'),
    ('吴', '女', '33'),
    ('郑', '男', '22'),
    ('王', '男', '11'));
var
  i: Integer;
  Item: TListItem;
  Column: TListColumn;
begin
    ListView1.Align := alTop;
    ListView1.ViewStyle := vsReport;
    ListView1.GridLines := True;
    ListView1.Checkboxes := True; {显示复选框}     Column := ListView1.Columns.Add;
    Column.Caption := '姓名';
    Column.Width := ListView1.Width div ;     Column := ListView1.Columns.Add;
    Column.Caption := '性别';
    Column.Width := ListView1.Width div ;     Column := ListView1.Columns.Add;
    Column.Caption := '年龄';
    Column.Width := ListView1.Width div ;   for i := Low(ps) to High(ps) do
  begin
    Item := ListView1.Items.Add;
    Item.Caption := ps[i][];
    Item.SubItems.Add(ps[i][]);
    Item.SubItems.Add(ps[i][]);
  end;   CheckBox1.Caption := 'RowSelect';
  Button1.Caption := '显示复选的项';
end; procedure TForm1.ListView1Change(Sender: TObject; Item: TListItem;
  Change: TItemChange);
begin
  if Item.SubItems.Count > then
    Text := Format('%s: %s, %s', [Item.Caption, Item.SubItems[], Item.SubItems[]]);
end; procedure TForm1.Button1Click(Sender: TObject);
var
  Item: TListItem;
  str: string;
begin
  str := '';
  for Item in ListView1.Items do
    if Item.Checked then
      str := str + Item.Caption + sLineBreak;
  ShowMessage(TrimRight(str));
end; procedure TForm1.CheckBox1Click(Sender: TObject);
begin
  ListView1.RowSelect := CheckBox1.Checked;
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
  Position = poDesktopCenter
  OnCreate = FormCreate
  PixelsPerInch =
  TextHeight =
  object ListView1: TListView
    Left =
    Top =
    Width =
    Height =
    Columns = <>
    TabOrder =
    OnChange = ListView1Change
  end
  object Button1: TButton
    Left =
    Top =
    Width =
    Height =
    Caption = 'Button1'
    TabOrder =
    OnClick = Button1Click
  end
  object CheckBox1: TCheckBox
    Left =
    Top =
    Width =
    Height =
    Caption = 'CheckBox1'
    TabOrder =
    OnClick = CheckBox1Click
  end
end

使用 TListView 控件(4)的更多相关文章

  1. Delphi的TListView控件拖放选定行操作

    http://www.tansoo.cn/?p=401 Delphi的TListView控件拖放选定行操作的例子,效果图如下:TListView控件拖动选定行到指定位置 具体实现步骤: 一.新建一个D ...

  2. c++ builder TListView控件按字符串排序(根据网上代码亲测ok)

    //--------------------------------------------------------------------------- /* 首先将一个列表框控件安放在Form上, ...

  3. 使用 TListView 控件(2)

    本例效果图: 代码文件: unit Unit1; interface uses   Windows, Messages, SysUtils, Variants, Classes, Graphics, ...

  4. TListView控件的ReadOnly属性的一个Bug

    不知道是不是ListView的 ReadOnly属性的一个bug 1.Form上一个ListView,如图设置 2.在FormCreate事件中写如下代码:     ListView1->Rea ...

  5. 教程-Delphi第三方控件安装卸载指南

    1 只有一个DCU文件的组件.DCU文件是编译好的单元文件,这样的组件是作者不想把源码公布.一般来说,作者必须说明此组件适合Delphi的哪种版本,如果版本不对,在安装时就会出现错误.也正是因为没有源 ...

  6. Delphi 7 里没有加载的控件

    在原来版本如D5.D6中使用的控件如Quickrep,FastNet等,在D7中仍然是保留的.只是Delphi没有将他们默认的安装到组件面版中来.这些控件包全部保存在Delphi目录的bin下,文件扩 ...

  7. 教程-Delphi7 自带控件安装对应表

    原来的控件delphi7里何处寻? 经常有朋友提这样的问题,“我原来在delphi5或者delphi6中用的很熟的控件到哪里去了?是不是在delphi7中没有了呢?这是不是意味着我以前写的代码全都不能 ...

  8. Delphi中解析Xml的控件-SimDesign NativeXml

    Delphi中解析Xml的控件-SimDesign NativeXml 正在学习,感觉应用很方便.无源代码的版本还是免费的. SimDesign.NativeXml是一个delphi和bcb的XML控 ...

  9. Delphi在Listview中加入Edit控件

    原帖 : http://www.cnblogs.com/hssbsw/archive/2012/06/03/2533092.html Listview是一个非常有用的控件,我们常常将大量的数据(如数据 ...

随机推荐

  1. IO多路复用select/poll/epoll详解以及在Python中的应用

    IO multiplexing(IO多路复用) IO多路复用,有些地方称之为event driven IO(事件驱动IO). 它的好处在于单个进程可以处理多个网络IO请求.select/epoll这两 ...

  2. Android 多用户多缓存的简单处理方案

    需求:1.在缓存中记录用户登录信息.例如:用户名,密码 2.记录用户操作数据.例如:是否记住用户名密码.设置7天内自动登录等 简单设计:1)使用sqlite设计一张用户数据表,有用户名.密码.操作数据 ...

  3. P1272 重建道路

    题目描述 一场可怕的地震后,人们用N个牲口棚(1≤N≤150,编号1..N)重建了农夫John的牧场.由于人们没有时间建设多余的道路,所以现在从一个牲口棚到另一个牲口棚的道路是惟一的.因此,牧场运输系 ...

  4. jqgrid 批量启动所有行为可编辑状态

    有时,为操作方便,需要将jqgrid表格设置为一直处于编辑状态,用户只需要在对应的编辑区填写自己信息,不再频繁的去触发行编辑和保存. 参考代码如下: //$gridCase为传入jqgrid对象 fu ...

  5. 王立平--查看SQLite中的数据信息

    Eclipse菜单Window - Open Perspective - DDMS进入DDMS视图. 然后File Explorer View中依次展开路径/data/data/package_nam ...

  6. Educational Codeforces Round 41 (Rated for Div. 2)(A~D)

    由于之前打过了这场比赛的E题,而后面两道题太难,所以就手速半个多小时A了前4题. 就当练手速吧,不过今天除了C题数组开小了以外都是1A A Tetris 题意的抽象解释可以在Luogu里看一下(话说现 ...

  7. 汇编 循环位移指令 ROL, 循环位移指令 ROR

    知识点:  循环位移指令 ROL  循环位移指令 ROR 一.循环位移指令 ROL ROR int i=0x77886611;//01110111100010000110011000010001 ...

  8. springboot @PropertySource

    @ConfigurationProperties(prefix="person") 默认加载全局配置文件 application.properties或application.ym ...

  9. JavaScript快速入门-ECMAScript本地对象(Date)

    JavaScript中的Date 对象用于处理日期和时间. var myDate=new Date()  #Date 对象会自动把当前日期和时间保存为其初始值. 一.Date对象的方法 方法 示例 n ...

  10. Js_封装JQ库为插件

    //在jQuery匿名函数中,采用jQuery.extend();方法创建jQuery插件 //在jQuery匿名函数中, 采用对象.属性 = 函数的方式创建jQuery插件 (function ($ ...