Autor Beitrag
Borg-Cube
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 38


Delphi 2009
BeitragVerfasst: So 11.01.04 20:54 
Hallo

ich habe hier eine Listview. Da packe ich sachen aus einer Datenbank rein. Leider ist die Darstellung sehr verzerrt und nicht zu gebrauchen.

Folgender Code wird benutzt:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
    listitem.Items.add.Caption:='Feld1';
    listitem.Items.add.SubItems.Add('Feld2');
    listitem.Items.add.SubItems.Add('Feld3');
    listitem.Items.add.SubItems.Add('Feld4');

Dabei kommt folgendes raus:
user defined image

Das ist ja quatsch und hilft mir nicht weiter, denn es soll ja so aussehen:
user defined image

Was muss ich am COde abändern, damit das hinhaut?
Keldorn
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 2266
Erhaltene Danke: 4

Vista
D6 Prof, D 2005 Pro, D2007 Pro, DelphiXE2 Pro
BeitragVerfasst: So 11.01.04 20:59 
Hallo

steht doch in der onlinehilfe, da ist ein Beispiel.
Zitat:

listitem.Items.add. ...

du fügst jedesmal ein Item hinzu und hängst dort ein subitem dran, dadurch entsehen 4 Zeilen
geh über ein Hilfsitem, wo du das angelegte, neue Listitem hinterlegst
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
var myListItem:Tlistitem;
...
begin 
  mylistitem:=listview.Items.add;
  mylistitem.caption := 'vcvx';
  mylistitem.subitems.add('fsdf');
...

direkt ins Forum geklimpert ;)

Mfg Frank

_________________
Lükes Grundlage der Programmierung: Es wird nicht funktionieren.
(Murphy)
CenBells
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1547

Win 7
Delphi XE5 Pro
BeitragVerfasst: So 11.01.04 21:01 
Hallo,

entweder machst du es so:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
    with listitem.Items.add do begin
    Caption:='Feld1'; 
    SubItems.Add('Feld2'); 
    SubItems.Add('Feld3'); 
    SubItems.Add('Feld4');
end;

oder du machst es so

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
var
  LItem: TListItem;
...
  LItem := listitem.Items.add;
  LItem.Caption:='Feld1'; 
  LItem.SubItems.Add('Feld2'); 
  LItem.SubItems.Add('Feld3'); 
  LItem.SubItems.Add('Feld4');


Ein blick in die Delphi-hilfe zu TListitems.add hätte dir das selbe erklärt ;)
// mist zu spät
Gruß
Ken

_________________
Eine Klasse beschreibt die Struktur und das Verhalten einer Menge gleichartiger Objekte.
Borg-Cube Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 38


Delphi 2009
BeitragVerfasst: So 11.01.04 21:07 
danke.
Hat geklappt.