以下以一个两列的ListView为例
→增加一行:
with ListView1 do
begin
ListItem := Items.Add;
ListItem.Caption := '第一列内容';
ListItem.SubItems.Add('第二列内容');
end;
那如果是多列应该怎么加?比如要在第4列第5行加入"第4列第5行",应该怎么做?
回答一定给分!!
→增加一行:
with ListView1 do
begin
ListItem := Items.Add;
ListItem.Caption := '第一列内容';
ListItem.SubItems.Add('第二列内容');
end;
那如果是多列应该怎么加?比如要在第4列第5行加入"第4列第5行",应该怎么做?
回答一定给分!!
columns 不要望了添加
with ListView1 do
begin
ListItem := Items.Add;
ListItem.Caption := '第一列内容';
ListItem.SubItems.Add('第二列内容');
ListItem.SubItems.Add('第二列内容');
ListItem.SubItems.Add('第二列内容');
ListItem := Items.Add;
ListItem.Caption := '第一列内容';
ListItem.SubItems.Add('第二列内容');
end;
自己写程序在看吧
Names: array[0..5, 0..1] ofstring = (
('Rubble', 'Barney'),
('Michael', 'Johnson'),
('Bunny', 'Bugs'),
('Silver', 'HiHo'),
('Simpson', 'Bart'),
('Squirrel', 'Rocky')
);var
I: Integer;
NewColumn: TListColumn;
ListItem: TListItem;
ListView: TListView;
begin
ListView := TListView.Create(Self);
with ListView do
begin
Parent := Self;
Align := alClient; ViewStyle := vsReport; NewColumn := Columns.Add;
NewColumn.Caption := 'Last';
NewColumn := Columns.Add;
NewColumn.Caption := 'First'; for I := Low(Names) to High(Names) do
begin
ListItem := Items.Add;
ListItem.Caption := Names[I][0];
ListItem.SubItems.Add(Names[I][1]);
end;
end;
end;