现有字符串数组..
s[0]='123';
s[1]='刘德华';
s[2]='123456';
s[3]='12345678'
s[4]='12';
s[5]='刘德清';
s[6]='123465';
s[7]='87654321'我需要把他显示到控件ListView里如下:123 刘德华 123456 12345678
12 刘德清 123465 87654321该怎么写代码呀?
s[0]='123';
s[1]='刘德华';
s[2]='123456';
s[3]='12345678'
s[4]='12';
s[5]='刘德清';
s[6]='123465';
s[7]='87654321'我需要把他显示到控件ListView里如下:123 刘德华 123456 12345678
12 刘德清 123465 87654321该怎么写代码呀?
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;//出自delphi的help
var i:integer;
s:TStringList;
ListItem:TListItem;
begin
s:=TStringList.Create;
s.Add('123');
s.Add('刘德华');
s.Add('123456');
s.Add('12345678');
s.Add('12');
s.Add('刘德清');
s.Add('123465');
s.Add('87654321');
for i:=1 to 4 do ListView1.Columns.Add;
ListView1.ViewStyle:=vsReport;
for i:=0 to 1 do
with ListView1 do
begin
ListItem:=Items.Add;
ListItem.Caption:=s[4*i];
with ListItem.SubItems do
begin
Add(s[4*i+1]);
Add(s[4*i+2]);
Add(s[4*i+3]);
end;
end;
s.Free;
end;