![]() |
Re: Ausgewählte Zeilen e. Stringgrid's i.e. anderes Stringg
Liste der Anhänge anzeigen (Anzahl: 1)
Habe Colcount bei beiden bei 3 und Rowcount bei beiden bei 2.
So sieht der Code gerade aus:
Delphi-Quellcode:
Freundliche Grüße
procedure Tform1.Button2Click(Sender: TObject);
var i, x2: integer; begin for i := 1 to StringGrid1.RowCount -1 do for x2 := 1 to StringGrid1.ColCount-1 do begin if stringgrid1.GetCheckBoxState(0,i,state) then begin if state = true then StringGrid2.Cells[i, x2-1]:=StringGrid1.Cells[i, x2-1]; end; end; end; Aaron [EDIT] schau dir mal bitte das Bild an. Außerdem ist mir aufgefallen, wenn das zweite stringgrid wieder die gleichen Dimensionen hat bekomme ich beim Ausdruck genau die gleichen Felder angezeigt. Das will ich ja danach damit machen, habs bislang nicht erwähn weil ich nicht wußte wie es weiter geht. ![]() |
Re: Ausgewählte Zeilen e. Stringgrid's i.e. anderes Stringg
Lass mal die Abfrage der Checkboxen weg.
|
Re: Ausgewählte Zeilen e. Stringgrid's i.e. anderes Stringg
Dann wird immer noch eine Zeile angezeigt.
|
Re: Ausgewählte Zeilen e. Stringgrid's i.e. anderes Stringg
Liste der Anhänge anzeigen (Anzahl: 1)
Ich hab es mal mit normalen StringGrids getestet, funktioniert
Delphi-Quellcode:
unit Unit1;
interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, Grids, StdCtrls; type TForm1 = class(TForm) Button1: TButton; StringGrid1: TStringGrid; StringGrid2: TStringGrid; procedure Button1Click(Sender: TObject); procedure FormCreate(Sender: TObject); private { Private-Deklarationen } public { Public-Deklarationen } end; var Form1: TForm1; implementation {$R *.dfm} procedure TForm1.Button1Click(Sender: TObject); var i, x2: integer; begin for i := 1 to StringGrid1.RowCount -1 do for x2 := 1 to StringGrid1.ColCount-1 do begin //if stringgrid1.GetCheckBoxState(0,i,state) then begin //if state = true then StringGrid2.Cells[i, x2]:=StringGrid1.Cells[i, x2]; end; end; end; procedure TForm1.FormCreate(Sender: TObject); begin StringGrid1.rows[0].CommaText := 'Spalte1, Spalte2, Spalte3'; StringGrid1.rows[1].CommaText := 'blabla, a , b, c'; StringGrid1.rows[2].CommaText := 'ablabl, 1 , 2, 3'; end; end. |
Re: Ausgewählte Zeilen e. Stringgrid's i.e. anderes Stringg
Liste der Anhänge anzeigen (Anzahl: 1)
Stimmt, das funktioniert.
Ich bau das jetzt auf einer anderern Form mal mit den Checkboxen, bin ja gespannt. Gruß Aaron [Edit] Mit den Checkboxen funktioniert es wieder nicht. (Screenshot) |
Re: Ausgewählte Zeilen e. Stringgrid's i.e. anderes Stringg
Das mit der Listbox klappt:
Delphi-Quellcode:
procedure TForm1.Button2Click(Sender: TObject);
var i: Integer; state: boolean; begin Listbox1.Items.Clear; for i := 1 to StringGrid1.RowCount - 1 do begin if stringgrid1.GetCheckBoxState(0,i,state) then begin if state then begin StringGrid1.SetCheckBoxState(0,i,false); ListBox1.Items.Add(Stringgrid1.Cells[1,i]+Stringgrid1.Cells[2,i]); end; end; end; if listbox1.Items.Count = 0 then ShowMessage('No items selected'); StringGrid1.Invalidate; end; |
Re: Ausgewählte Zeilen e. Stringgrid's i.e. anderes Stringg
So komme ich nun auch ans Ziel, obwohl ich ja gerne gewußt hätte was ich falsch mache:
Delphi-Quellcode:
Freundliche Grüße
procedure TForm1.Button1Click(Sender: TObject);
var i: Integer; state: boolean; begin Listbox1.Items.Clear; for i := 1 to StringGrid1.RowCount - 1 do begin if stringgrid1.GetCheckBoxState(0,i,state) then begin if state then begin StringGrid1.SetCheckBoxState(0,i,false); ListBox1.Items.Add(Stringgrid1.Cells[1,i]+';'+Stringgrid1.Cells[2,i]); ListBox1.Items.SaveToFile(extractfilepath(application.exename)+'data\tmp.txt'); end; end; end; if listbox1.Items.Count = 0 then ShowMessage('No items selected'); StringGrid1.Invalidate; StringGrid2.Clear; Form1.StringGrid2.Delimiter := ';'; StringGrid2.loadfromCSV(extractfilepath(application.exename)+'data\tmp.txt'); end; Aaron |
Re: Ausgewählte Zeilen e. Stringgrid's i.e. anderes Stringg
Ich kenne die TMS-Komponente leider nicht.
|
Re: Ausgewählte Zeilen e. Stringgrid's i.e. anderes Stringg
Die sind echt gut, erleichtern "manchmal" die Arbeit.
Ich möchte mich für deine Hilfe nochmal bei dir bedanken. Gruß Aaron |
Re: Ausgewählte Zeilen e. Stringgrid's i.e. anderes Stringg
Ich werde mir mal die Demoversion herunterladen.
Könntest du mir dein Testprojekt mal einstellen? |
Alle Zeitangaben in WEZ +1. Es ist jetzt 11:21 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz