I';我在Delphi XE3的图片中寻找这样的列表?

I';我在Delphi XE3的图片中寻找这样的列表?,delphi,listview,listbox,delphi-xe3,Delphi,Listview,Listbox,Delphi Xe3,有人知道在Delphi XE3中在哪里找到或如何制作这样的列表吗? 还是该离开Delphi使用Visual studio了 然而,这个网站声称这个控件可以与.NET一起使用,我相信Delphi支持.NET,但我以前没有与Delphi一起使用.NET,你认为它可以与Delphi.NET一起使用吗 经过艰苦的搜索,我找到了这段代码,它模仿列表视图来实现列表的分组类型,在Timagelist列表的帮助下,你可以创建自己的箭头状图标 谢谢你 单元1; 接口 使用 继续, 窗口、消息、系统工具、变体、类、

有人知道在Delphi XE3中在哪里找到或如何制作这样的列表吗? 还是该离开Delphi使用Visual studio了

然而,这个网站声称这个控件可以与.NET一起使用,我相信Delphi支持.NET,但我以前没有与Delphi一起使用.NET,你认为它可以与Delphi.NET一起使用吗


经过艰苦的搜索,我找到了这段代码,它模仿列表视图来实现列表的分组类型,在Timagelist列表的帮助下,你可以创建自己的箭头状图标

谢谢你

单元1;
接口
使用
继续,
窗口、消息、系统工具、变体、类、图形、控件、窗体、,
对话、ImgList、ComCtrls;
类型
TGroupItem=class
私有的
fItems:TObjectList;
fCaption:字符串;
fListItem:TListItem;
fExpanded:布尔型;
函数GetItems:TObjectList;
公众的
构造函数创建(const标题:string;const numberOfSubItems:integer);
毁灭者毁灭;推翻
程序扩展;
程序崩溃;
已展开的属性:布尔读取已展开;
属性标题:字符串读取fCaption;
属性项:TObjectList读取GetItems;
属性列表项:TListItem read fListItem write fListItem;
结束;
TItem=类
私有的
fTitle:字符串;
fValue:string;
公众的
构造函数创建(const title,value:string);
属性标题:字符串读取fTitle;
属性值:字符串读取值;
结束;
TForm1=类(TForm)
LV组:TListView;
listViewImages:TImageList;
过程表单创建(发送方:ToObject);
销毁程序表(发送方:TObject);
过程lvGroupsAdvancedCustomDrawItem(发送方:TCustomListView;
项目:TListItem;状态:TCustomDrawState;阶段:TCustomDrawStage;
var DefaultDraw:Boolean);
过程lvGroupsDblClick(发送方:TObject);
私有的
程序ClearListViewGroup;
程序filllistviewgroup;
公众的
{公开声明}
结束;
变量
表1:TForm1;
实施
{$R*.dfm}
程序TForm1.ClearListViewGroups;
变量
李:系统,;
qng:tgroup项目;
开始
对于LV组中的li。项目是否执行
开始
如果TObject(li.Data)是TGroupItem,那么
开始
qng:=TGroupItem(li.数据);
FreeAndNil(qng);
结束;
结束;
三组。清楚;
结束;
程序TForm1.FillListViewGroups;
程序AddGroupItem(gi:TGroupItem);
变量
李:系统,;
开始
li:=lvGroups.Items.Add;
li.Caption:=gi.Caption;
li.ImageIndex:=1//崩溃
li.数据:=gi;
gi.ListItem:=li//链接“返回”
结束;
开始
ClearListViewGroup;
AddGroupItem(TGroupItem.Create('groupa',3));
AddGroupItem(TGroupItem.Create('Group B',1));
AddGroupItem(TGroupItem.Create('groupC',4));
AddGroupItem(TGroupItem.Create('groupd',5));
AddGroupItem(TGroupItem.Create('groupd',5));
AddGroupItem(TGroupItem.Create('groupd',5));
AddGroupItem(TGroupItem.Create('groupd',5));
结束;
过程TForm1.FormCreate(发送方:TObject);
开始
FillListViewGroup;
结束;
程序TForm1.FormDestroy(发送方:ToObject);
开始
ClearListViewGroup;
结束;
过程TForm1.lvGroupsAdvancedCustomDrawItem(发送方:TCustomListView;
项目:TListItem;状态:TCustomDrawState;阶段:TCustomDrawStage;
var DefaultDraw:Boolean);
开始
//粗体分组项目
如果TObject(item.Data)是TGroupItem,则
开始
lvGroups.Canvas.Font.Style:=lvGroups.Canvas.Font.Style+[fsBold];
结束;
结束;
//处理TListView ONDBL偶数单击
过程TForm1.lvGroupsDblClick(发送方:TObject);
变量
hts:thittes;
gi:tgroup项目;
开始
继承;
hts:=lvGroups.getHitTestInfo(lvGroups.ScreenToClient(Mouse.CursorPos).X,lvGroups.ScreenToClient(Mouse.CursorPos.y);
如果(lvGroups.Selected nil),则
开始
如果TObject(lvGroups.Selected.Data)是(TGroupItem),则
开始
gi:=TGroupItem(lvGroups.Selected.Data);
如果不是gi,那么扩展
gi.扩展
其他的
gi.崩塌;
结束;
结束;
结束;
{$region'TGroupItem'}
过程TGroupItem.Collapse;
变量
李:系统,;
开始
如果没有扩展,则退出;
ListItem.ImageIndex:=1;
fExpanded:=假;
li:=TListView(ListItem.ListView).Items[ListItem.Index+1];
而(linil)和(TObject(li.Data)是TItem)do
开始
TListView(ListItem.ListView).Items.Delete(li.Index);
li:=TListView(ListItem.ListView).Items[ListItem.Index+1];
结束;
结束;
构造函数TGroupItem.Create(常量标题:string;常量numberOfSubItems:integer);
变量
cnt:整数;
开始
fCaption:=标题;
对于cnt:=1到numberOfSubItems do
开始
Items.Add(TItem.Create(标题+item'+IntToStr(cnt),IntToStr(cnt));
结束;
结束;
析构函数TGroupItem.Destroy;
开始
FreeAndNil(fItems);
继承;
结束;
程序TGroupItem.Expand;
变量
cnt:整数;
项目:滴度;
开始
如果扩展,则退出;
ListItem.ImageIndex:=0;
fExpanded:=真;
对于cnt:=0到-1+项。计数do
开始
项目:=滴度(项目[cnt]);
使用TListView(ListItem.ListView).Items.Insert(1+cnt+ListItem.Index)执行以下操作
开始
标题:=项目名称;
子项。添加(项。值);
数据:=项目;
ImageIndex:=-1;
结束;
结束;
结束;
函数TGroupItem.GetItems:TObjectList;
开始
如果fItems=nil,则fItems:=TObjectList.Create(true);
结果:=fItems;
结束;
{$endregion}
{$region'TItem'}
构造函数TItem.Create(const title,value:string);
开始
fTitle:=标题;
fValue:=值;
结束;
{$endregion}
结束。

经过艰苦的搜索,我找到了这段代码,它模仿列表视图来实现列表的分组类型,在Timagelist列表的帮助下,你可以创建自己的箭头状图标

谢谢你

单元1;
接口
使用
继续,
窗口、消息、系统工具、变体、类、图形、控件、窗体、,
对话、ImgList、ComCtrls;
类型
TGroupItem=class
私有的
菲特姆斯:托比切利
unit Unit1;

interface


uses
  Contnrs,
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ImgList, ComCtrls;

type
  TGroupItem = class
  private
    fItems : TObjectList;
    fCaption: string;
    fListItem: TListItem;
    fExpanded: boolean;
    function GetItems: TObjectList;
  public
    constructor Create(const caption : string; const numberOfSubItems : integer);
    destructor Destroy; override;

    procedure Expand;
    procedure Collapse;

    property Expanded : boolean read fExpanded;
    property Caption : string read fCaption;
    property Items : TObjectList read GetItems;
    property ListItem : TListItem read fListItem write fListItem;
  end;

  TItem = class
  private
    fTitle: string;
    fValue: string;
  public
    constructor Create(const title, value : string);
    property Title: string read fTitle;
    property Value : string read fValue;
  end;


  TForm1 = class(TForm)
    lvGroups: TListView;
    listViewImages: TImageList;
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
    procedure lvGroupsAdvancedCustomDrawItem(Sender: TCustomListView;
      Item: TListItem; State: TCustomDrawState; Stage: TCustomDrawStage;
      var DefaultDraw: Boolean);
    procedure lvGroupsDblClick(Sender: TObject);
  private
    procedure ClearListViewGroups;
    procedure FillListViewGroups;
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}
procedure TForm1.ClearListViewGroups;
var
  li : TListItem;
  qng : TGroupItem;
begin
  for li in lvGroups.Items do
  begin
    if TObject(li.Data) is TGroupItem then
    begin
      qng := TGroupItem(li.Data);
      FreeAndNil(qng);
    end;
  end;
  lvGroups.Clear;
end;

procedure TForm1.FillListViewGroups;

  procedure AddGroupItem(gi : TGroupItem);
  var
    li : TListItem;
  begin
    li := lvGroups.Items.Add;

    li.Caption := gi.Caption;
    li.ImageIndex := 1; //collapsed

    li.Data := gi;
    gi.ListItem := li; //link "back"
  end;
begin
  ClearListViewGroups;

  AddGroupItem(TGroupItem.Create('Group A', 3));
  AddGroupItem(TGroupItem.Create('Group B', 1));
  AddGroupItem(TGroupItem.Create('Group C', 4));
  AddGroupItem(TGroupItem.Create('Group D', 5));
 AddGroupItem(TGroupItem.Create('Group D', 5));
  AddGroupItem(TGroupItem.Create('Group D', 5));
   AddGroupItem(TGroupItem.Create('Group D', 5));

end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  FillListViewGroups;
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
  ClearListViewGroups;
end;

procedure TForm1.lvGroupsAdvancedCustomDrawItem(Sender: TCustomListView;
  Item: TListItem; State: TCustomDrawState; Stage: TCustomDrawStage;
  var DefaultDraw: Boolean);
begin
  //bold group items
  if TObject(item.Data) is TGroupItem then
  begin
    lvGroups.Canvas.Font.Style := lvGroups.Canvas.Font.Style + [fsBold];
  end;
end;

//handles TListView OnDblClick even
procedure TForm1.lvGroupsDblClick(Sender: TObject);
var
  hts : THitTests;
  gi : TGroupItem;
begin
  inherited;

  hts := lvGroups.GetHitTestInfoAt(lvGroups.ScreenToClient(Mouse.CursorPos).X, lvGroups.ScreenToClient(Mouse.CursorPos).y);

  if (lvGroups.Selected <> nil) then
  begin
    if TObject(lvGroups.Selected.Data) is (TGroupItem) then
    begin
      gi := TGroupItem(lvGroups.Selected.Data);

      if NOT gi.Expanded then
        gi.Expand
      else
        gi.Collapse;
    end;
  end;
end;


{$region 'TGroupItem'}

procedure TGroupItem.Collapse;
var
  li : TListItem;
begin
  if NOT Expanded then Exit;

  ListItem.ImageIndex := 1;
  fExpanded := false;

  li := TListView(ListItem.ListView).Items[ListItem.Index + 1];
  while (li <> nil) AND (TObject(li.Data) is TItem) do
  begin
    TListView(ListItem.ListView).Items.Delete(li.Index);
    li := TListView(ListItem.ListView).Items[ListItem.Index + 1];
  end;
end;

constructor TGroupItem.Create(const caption: string; const numberOfSubItems : integer);
var
  cnt : integer;
begin
  fCaption := caption;

  for cnt := 1 to numberOfSubItems do
  begin
    Items.Add(TItem.Create(caption + ' item ' + IntToStr(cnt), IntToStr(cnt)));
  end;
end;

destructor TGroupItem.Destroy;
begin
  FreeAndNil(fItems);
  inherited;
end;

procedure TGroupItem.Expand;
var
  cnt : integer;
  item : TItem;
begin
  if Expanded then Exit;

  ListItem.ImageIndex := 0;
  fExpanded := true;

  for cnt := 0 to -1 + Items.Count do
  begin
    item := TItem(Items[cnt]);
    with TListView(ListItem.ListView).Items.Insert(1 + cnt + ListItem.Index) do
    begin
      Caption := item.Title;
      SubItems.Add(item.Value);
      Data := item;
      ImageIndex := -1;
    end;
  end;
end;

function TGroupItem.GetItems: TObjectList;
begin
  if fItems = nil then fItems := TObjectList.Create(true);
  result := fItems;
end;
{$endregion}

{$region 'TItem' }

constructor TItem.Create(const title, value: string);
begin
  fTitle := title;
  fValue := value;
end;
{$endregion}

end.