Autor Beitrag
superchatti
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 296

Win XP, Red Hat Linux 7.3
Delphi 6 PE
BeitragVerfasst: So 18.05.03 15:43 
Wie mache ich sowas! Er soll das speichern. Mit SubItems. Wenn er es lädt dann soll er nur Caption laden und die SubItems nicht!

Moderiert von user profile iconTino: Absätze entfernt.

_________________
mfG Superchatti
Wolff68
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 302
Erhaltene Danke: 1

WinXP home
D6 Prof
BeitragVerfasst: Di 20.05.03 20:02 
Ein Tip wäre die Suchfunktion des Forums zu benutzen.

Über ListViews wurde hier echt schon viel geschrieben. Zu Deinem speziellen Problem kannst hier was nachlesen. Vielleicht finden sich in diesem Forum auch noch bessere Methoden!?

Nix für ungut. :wink:

Moderiert von user profile iconTino: Absätze entfernt.

_________________
"Der Mensch ist nicht was er sich vorstellt oder wünscht zu sein, sondern das was andere in ihm sehen."
superchatti Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 296

Win XP, Red Hat Linux 7.3
Delphi 6 PE
BeitragVerfasst: Di 20.05.03 20:04 
Das kann sein!

_________________
mfG Superchatti
matze
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 4613
Erhaltene Danke: 24

XP home, prof
Delphi 2009 Prof,
BeitragVerfasst: Mi 21.05.03 15:07 
es gib nen befehl der heisst irgendwie saveComponentToFileStream oder so, damit kann man das machen. cih such mal und schreibst dann wenn ichs gefunden hab.

_________________
In the beginning was the word.
And the word was content-type: text/plain.
superchatti Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 296

Win XP, Red Hat Linux 7.3
Delphi 6 PE
BeitragVerfasst: Mi 21.05.03 15:23 
Ok!
Danke schonmal im voraus!

_________________
mfG Superchatti
matze
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 4613
Erhaltene Danke: 24

XP home, prof
Delphi 2009 Prof,
BeitragVerfasst: Do 22.05.03 13:29 
speichern:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
var
  F: TFileStream;
begin
  F := TFileStream.Create('c:\ListView.txt',fmCreate or fmShareCompat);
  F.WriteComponent(ListView1); //auslesen der Kompo in einen Stream
  F.Free;
end;


laden:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
var
  F : TFileStream;
begin
  F := TFileStream.Create('c:\ListView.txt',fmOpenRead or fmShareDenyWrite);
  F.ReadComponent(ListView1); //einlesen der Listview
  F.Free;
end;

_________________
In the beginning was the word.
And the word was content-type: text/plain.
superchatti Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 296

Win XP, Red Hat Linux 7.3
Delphi 6 PE
BeitragVerfasst: Do 22.05.03 17:17 
Tja...
Das heißt er speichert alles!
Aber kann er auch unterscheiden zwischen HauptItem und SubItem??

_________________
mfG Superchatti
superchatti Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 296

Win XP, Red Hat Linux 7.3
Delphi 6 PE
BeitragVerfasst: Do 22.05.03 17:21 
Cool!
Danke!
Es klappt Perfekt!

_________________
mfG Superchatti
matze
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 4613
Erhaltene Danke: 24

XP home, prof
Delphi 2009 Prof,
BeitragVerfasst: Do 22.05.03 18:01 
er speichert alle eigenschaften der kompo. also auch z.b. wie breit die spalten sind wenn du den style auf report hast

_________________
In the beginning was the word.
And the word was content-type: text/plain.
superchatti Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 296

Win XP, Red Hat Linux 7.3
Delphi 6 PE
BeitragVerfasst: Do 22.05.03 18:13 
das ist cool!
Aber irgendwie zeigt der jetzt an:
Exception der Klasse: EComponentError aufgetreten! Meldung: 'Komponente mit der Bezeichnung ListView1 existiert bereits.'

Hier der Code:
speichern:
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
procedure TfrmMain.FormShow(Sender: TObject);
var 
  F : TFileStream;
begin
If NOT FileExists('kontakte.k') then exit;
  F := TFileStream.Create('kontakte.k',fmOpenRead or fmShareDenyWrite);
  F.ReadComponent(ListView2);
  F.Free;
end;

laden:
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
procedure TfrmKontakte.Button1Click(Sender: TObject);
var
  F: TFileStream;
begin
  F := TFileStream.Create('kontakte.k',fmCreate or fmShareCompat);
  F.WriteComponent(ListView1);
  F.Free;
end;

was läuft da falsch??

_________________
mfG Superchatti
superchatti Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 296

Win XP, Red Hat Linux 7.3
Delphi 6 PE
BeitragVerfasst: Do 22.05.03 18:18 
Beim speichern sagt der:
EStringListError Meldung: 'ListIndex überschreitet das Maximum(1)'.

Was läuft da schief??
Der Code ist oben angezeigt!

_________________
mfG Superchatti
matze
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 4613
Erhaltene Danke: 24

XP home, prof
Delphi 2009 Prof,
BeitragVerfasst: Sa 24.05.03 09:44 
puh.... keine ahnung, bei mir leäft das einwandfrei !!!

was hast du denn für ne DelphiVerison ?

_________________
In the beginning was the word.
And the word was content-type: text/plain.
superchatti Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 296

Win XP, Red Hat Linux 7.3
Delphi 6 PE
BeitragVerfasst: Sa 24.05.03 11:14 
Naja!
Jetzt mach ich das anders!
Ich mache das jetzt mit GetToken!
Das ist eine uralte function.
Die läuft auch gut!

_________________
mfG Superchatti
matze
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 4613
Erhaltene Danke: 24

XP home, prof
Delphi 2009 Prof,
BeitragVerfasst: Sa 24.05.03 12:44 
du könntest dir natürlich auch mal die Hilfe zu den funktionen anschauen !!

nur mal so nebenbei: was macht GetToken ?

_________________
In the beginning was the word.
And the word was content-type: text/plain.
superchatti Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 296

Win XP, Red Hat Linux 7.3
Delphi 6 PE
BeitragVerfasst: Sa 24.05.03 12:57 
GetToken ist genau das gleiche nur vereinfacht!
Wenn du die Funktion haben willst sag es!
Mit Beispiel Code!

_________________
mfG Superchatti
matze
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 4613
Erhaltene Danke: 24

XP home, prof
Delphi 2009 Prof,
BeitragVerfasst: Sa 24.05.03 17:52 
jo. poste doch mal

_________________
In the beginning was the word.
And the word was content-type: text/plain.
superchatti Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 296

Win XP, Red Hat Linux 7.3
Delphi 6 PE
BeitragVerfasst: Sa 24.05.03 18:35 
Ok!
Hier der Code:

GetToken:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
function GetToken(aString: String; SepChar: Char; TokenNum: Byte):String;
var
   Token     : String;
   StrLen    : Byte;
   TNum      : Byte;
   TEnd      : Byte;

begin
  StrLen := Length(aString);
  TNum   := 1;
  TEnd   := StrLen;
  while ((TNum <= TokenNum) and (TEnd <> 0)) do begin
    TEnd := Pos(SepChar,aString);
    if TEnd <> 0 then begin
      Token := Copy(aString,1,TEnd-1);
      Delete(aString,1,TEnd);
      Inc(TNum);
    end else Token := aString;
  end;

  if TNum >= TokenNum then
    Result := Token
  else begin
    MessageDlg('Fehler: Tokennummer(' + aString + ' )ist größer als token !',mtError, [mbok], 0);
    Result := 'Fehler: Tokennummer(' + aString + ' )ist größer als token !';
  end;
end;


Speichern:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
var
di:TStringList;
i,x:integer;
begin
  DI:=TStringList.Create;

  for i:=0 to ListView1.Items.Count -1 do begin
    di.add(ListView1.Items[i].Caption );
     for x:=0 to 1 do begin//x ist abhängig von den SubItems! In diesem Fall 1 SubItem
      DI.Strings[di.count-1]:= DI.Strings[di.count-1]+ ','+ ListView1.Items[i].SubItems.Strings[x];
    end;
 end;
  DI.SaveToFile('ListView.txt'); // Konten speichen


Laden:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
var
Di:StringList;
i,x:integer;
DateiName:String
 begin
 ListView1.Items.Clear;
  DI:=TStringList.Create;
  DateiName:='ListView.txt';
  DI.LoadFromFile(DateiName);
  for i:=0 to di.count -1 do begin
    with ListView1.Items.add do begin
      Caption:=Trim(GetToken(di.strings[i], ',',1));
      ListView1.Items[ListView1.Items.Count-1].SubItems.add( GetToken(di.strings[i], ',',2) ) ;
 end;
end;

Das wars!
Ich hoffe du kannst damit was anfangen!!

_________________
mfG Superchatti


Zuletzt bearbeitet von superchatti am Do 23.10.03 11:16, insgesamt 1-mal bearbeitet
mimi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 3458

Ubuntu, Win XP
Lazarus
BeitragVerfasst: Sa 24.05.03 20:53 
nur so nebenbei: GetToken macht z.b: du hast ein String

Test1, Test2, Test3, Test4
und du willst nur Test2
nun könntes du z.b.
Gettoken(string, ',' 2); und fertig.

ich nutzt nur diese Funktion.

_________________
MFG
Michael Springwald, "kann kein englisch...."
superchatti Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 296

Win XP, Red Hat Linux 7.3
Delphi 6 PE
BeitragVerfasst: Sa 24.05.03 20:54 
Ich auch!

Im selben Project wie du!!

_________________
mfG Superchatti
superchatti Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 296

Win XP, Red Hat Linux 7.3
Delphi 6 PE
BeitragVerfasst: Sa 24.05.03 20:55 
Ach mimi??
Du bist doch da!
Warum kommst du nicht in den Chat??

_________________
mfG Superchatti