Autor Beitrag
raven
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 54



BeitragVerfasst: Mo 10.02.03 17:19 
hi

ich hab ein prob mit multi select vom open dialog ... ich möchte mehrere dateien markieren und die sollen dann untereinander in die listview rein mit den ganzen zugehörigen daten ...

das einfügen einer datei geht wunderbar nur sobald ich mehrere markiere gibt es nur noch komische einzelne buchstaben aus ...

hier der code:
(open=opendialog, filebox=listview, die sachen die eingefügt werden sind halt funktionen die daten der datei ermitteln)

ausblenden 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:
var
  i: integer;
begin
  if open.Execute then
  begin

    for i := 0 to open.Files.Count do
    begin

      with filebox.Items.add do
      begin
        caption := extractfilename(open.FileName[i]);

        subitems.Add(filesize(open.filename[i], true) + ' KB');

        subitems.Add(getfiletype(open.filename[i]));

        subitems.Add(FormatDateTime('dd/mm/yy hh:mm',
          filedate(Open.FileName[i])));

        subitems.add(open.filename[i]);

      end;
    end
  end;


kann mir einer sagen wo mein fehler ist?

danke
AXMD
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 4006
Erhaltene Danke: 7

Windows 10 64 bit
C# (Visual Studio 2019 Express)
BeitragVerfasst: Mo 10.02.03 17:26 
Hi,

bin mir nicht sicher, aber probiers doch mal mit einer TListItem-Variable anstatt des "with filebox.Items.add do"???

AXMD
Tino
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Veteran
Beiträge: 9839
Erhaltene Danke: 45

Windows 8.1
Delphi XE4
BeitragVerfasst: Mo 10.02.03 17:44 
Hallo,

zwei Sachen sind mir aufgefallen: Die For-To-Do Schleife darf höhstens bis Open.Fils.Count -1 laufen. Außerdem musst Du um den Dateinamen zu erhalten auf Open.Files zugreifen. Also so:
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
var 
  i: integer; 
begin 
  if open.Execute then 
  begin 
    for i := 0 to open.Files.Count -1 do 
    begin 
      with filebox.Items.add do 
      begin 
        caption := extractfilename(open.Files [i]); 
        subitems.Add(filesize(open.Files [i], true) + ' KB'); 
        subitems.Add(getfiletype(open.Files [i])); 
        subitems.Add(FormatDateTime('dd/mm/yy hh:mm', 
          filedate(Open.Files [i]))); 
        subitems.add(open.Files [i]); 
      end; 
    end 
  end;

Gruß
TINO