"Henning Madsen" <HKM@madsen.tdcadsl.dk> skrev i en meddelelse
news:42e63144$0$642$edfadb0f@dread12.news.tele.dk...
> Jeg glemte lige programmet
> procedure TForm1.FormCreate(Sender: TObject);
> const
> Navne: array[0..9, 0..2] of ShortString = (
> ('0..0','0..1','0..2'),
> ('1..0','1..1','1..2'),
> ('2..0','2..1','2..2'),
> ('3..0','3..1','3..2'),
> ('4..0','4..1','4..2'),
> ('5..0','5..1','5..2'),
> ('6..0','6..1','6..2'),
> ('7..0','7..1','7..2'),
> ('8..0','8..1','8..2'),
> ('9..0','9..1','9..2')
> );
>
> var
> I: integer;
> NewColumn: TListColumn;
> ListItem: TListItem;
> ListView: TListView;
> begin
> ListView := TListView.Create(Self);
> with ListView do
> begin
> Parent := Self;
> Align := alNone;
> ViewStyle := vsReport; //Hvordan data vises i ListView'en.
> GridLines := True; //Gitter linier vises.
> NewColumn := Columns.Add;
> NewColumn.Caption := '1.Kolonne';
> NewColumn := Columns.Add;
> NewColumn.Caption := '2.Kolonne';
> NewColumn := Columns.Add;
> NewColumn.Caption := '3.Kolonne';
>
> for I := 0 to High(Navne) do
> begin
> Edit1.Text := IntToStr(High(Navne)); //Antal linier fra Array'en.
> ListItem := Items.Add;
> ListItem.Caption := Navne[I][0];
> ListItem.SubItems.Add(Navne[I][1]);
> ListItem.SubItems.Add(Navne[I][2]);
> end;
> end;
> end;
> MVH
> Henning
Jeg ville gøre det sådan, lidt enklere. Men det er nok smag og behag.
procedure TForm1.FormCreate(Sender: TObject);
const
Navne: array[0..9, 0..2] of ShortString = (
('0..0','0..1','0..2'),
('1..0','1..1','1..2'),
('2..0','2..1','2..2'),
('3..0','3..1','3..2'),
('4..0','4..1','4..2'),
('5..0','5..1','5..2'),
('6..0','6..1','6..2'),
('7..0','7..1','7..2'),
('8..0','8..1','8..2'),
('9..0','9..1','9..2')
);
var
I: integer;
begin
with ListView do
begin
Parent := Self;
Align := alNone;
ViewStyle := vsReport; //Hvordan data vises i ListView'en.
GridLines := True; //Gitter linier vises.
Columns.Add.Caption:='1.Kolonne';
Columns.Add.Caption:='2.Kolonne';
Columns.Add.Caption:='3.Kolonne';
for I := 0 to High(Navne) do
begin
Edit1.Text := IntToStr(High(Navne)); //Antal linier fra Array'en.
with Items.Add do
begin
Caption := Navne[I][0];
SubItems.Add(Navne[I][1]);
SubItems.Add(Navne[I][2]);
end;
end;
end;
end;
|