Autor Beitrag
podi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 43

Win XP, Delphi 7,

BeitragVerfasst: So 15.10.06 11:37 
Hallo!
Kann man die Daten einer Tlistview mit einer Listbox 1:1 verknüpfen?
Wenn ja; wie?

Besten Dank

_________________
Freundliche Grüsse
alzaimar
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2889
Erhaltene Danke: 13

W2000, XP
D6E, BDS2006A, DevExpress
BeitragVerfasst: So 15.10.06 12:14 
Du müsstest zunächst die Items der ListView in die Items der ListBox kopieren. Leider sind die (obwohl sie gleich heißen) nicht 100% kompatibel, sodaß Du jeden Eintrag einzeln kopieren musst.

Schreib Dir dafür am Besten eine Methode 'CopyListViewToListBox'. In den Ereignissen 'OnEdited', 'OnDeletion' und 'OnInsert' rufst Du diese Methode einfach auf und -schwupps- enthält die Listbox immer die Daten, die man auch in der ListView sieht.

Was hast Du überhaupt vor?

_________________
Na denn, dann. Bis dann, denn.
podi Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 43

Win XP, Delphi 7,

BeitragVerfasst: So 15.10.06 12:25 
Was ich vor habe?
Hmm einfach eine Tlistview mit einem Button ausdrucken....
Ich weiss, dank gallagher, wie man dies mit einer Listbox kann!!

_________________
Freundliche Grüsse
Lannes
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2352
Erhaltene Danke: 4

Win XP, 95, 3.11, IE6
D3 Prof, D4 Standard, D2005 PE, TurboDelphi, Lazarus, D2010
BeitragVerfasst: So 15.10.06 17:33 
Hallo,

Du brauchst doch nur den Code von user profile icongalagher entsprechend anpassen:
ausblenden Delphi-Quelltext
1:
2:
for Line := 0 to ListView1.Items.Count - 1 do  
   Writeln(PrintText, ListView1.Items[Line].Caption);

mit Caption greift man auf die erste Spalte der ListView zu.

Die weiteren Spalten kann man z.B. mit
ausblenden Delphi-Quelltext
1:
ListView1.Items[Line].SubItems[0];					
ansprechen, der Index 0 ist die zweite Spalte der ListView.

_________________
MfG Lannes
(Nichts ist nicht Nichts) and ('' <> nil ) and (Pointer('') = nil ) and (@('') <> nil )
podi Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 43

Win XP, Delphi 7,

BeitragVerfasst: So 15.10.06 18:26 
Leider geht das nicht...
irgend eine Fehlermeldung von Eception der Klasse EAccessViolation!!!???

Was zum Geier soll das denn wieder??

_________________
Freundliche Grüsse
Lannes
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2352
Erhaltene Danke: 4

Win XP, 95, 3.11, IE6
D3 Prof, D4 Standard, D2005 PE, TurboDelphi, Lazarus, D2010
BeitragVerfasst: So 15.10.06 23:16 
Hallo,

wann/wo passiert die Zugriffsverletzung?
Etwas Code könnte weiterhelfen.

_________________
MfG Lannes
(Nichts ist nicht Nichts) and ('' <> nil ) and (Pointer('') = nil ) and (@('') <> nil )
podi Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 43

Win XP, Delphi 7,

BeitragVerfasst: Mo 16.10.06 20:42 
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:
procedure TMainForm.Copyitemlisttolistbox1(Sender: TObject);
  var

  Line: Integer;
  PrintText: System.Text;


  begin
 if PrintDialog1.Execute then
 begin
  AssignPrn(PrintText);  
  Rewrite(PrintText);  
  Printer.Canvas.Font := ListBox1.Font;


  for Line := 0 to ListBox1.Items.Count - 1 do  
   Writeln(PrintText, ListBox1.Items[Line]);  


  System.Close(PrintText);
 end;  
end;


Moderiert von user profile iconraziel: Highlight- durch Delphi-Tags ersetzt

_________________
Freundliche Grüsse
wulfskin
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1349
Erhaltene Danke: 1

Win XP
D5 Pers (SSL), D2005 Pro, C, C#
BeitragVerfasst: Mo 16.10.06 22:02 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
 var
  Line, SubItem: Integer;
  PrintText: System.Text;
  ListItem: TListItem;
begin
  if PrintDialog1.Execute then
  begin
    AssignPrn(PrintText);
    Rewrite(PrintText);
    Printer.Canvas.Font := ListBox1.Font;
    for Line := 0 to ListView.Items.Count - 1 do
    begin
      ListItem := ListView.Items[Line];
      Writeln(PrintText, ListItem.Caption);
      for SubItem := 0 to ListItemSubItems.Count -1 do
        WriteLn(PrintText, ListItem.SubItems[SubItem]);
    end;
    System.Close(PrintText);
  end;
end;
Aus dem Kopf. Wenn ein Fehler kommt, _erst_ mal selber überlegen, den Debugger zur Hilfe holen und eventuell die Delphi Hilfe (F1) aufmachen. Erst dann, noch mal schreiben.

Gruß Hape!

_________________
Manche antworten um ihren Beitragszähler zu erhöhen, andere um zu Helfen.