AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein GUI-Design mit VCL / FireMonkey / Common Controls Delphi Ausgewählte Zeilen e. Stringgrid's i.e. anderes Stringgrid

Ausgewählte Zeilen e. Stringgrid's i.e. anderes Stringgrid

Ein Thema von aaron · begonnen am 24. Mär 2008 · letzter Beitrag vom 24. Mär 2008
Antwort Antwort
Seite 2 von 3     12 3   
aaron

Registriert seit: 18. Feb 2003
202 Beiträge
 
Delphi 2007 Professional
 
#11

Re: Ausgewählte Zeilen e. Stringgrid's i.e. anderes Stringg

  Alt 24. Mär 2008, 12:29
Habe Colcount bei beiden bei 3 und Rowcount bei beiden bei 2.
So sieht der Code gerade aus:
Delphi-Quellcode:
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;
Freundliche Grüße
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.
http://www.delphipraxis.net/internal...200&highlight=
Miniaturansicht angehängter Grafiken
besipiel_816.jpg  
  Mit Zitat antworten Zitat
mkinzler
(Moderator)

Registriert seit: 9. Dez 2005
Ort: Heilbronn
39.851 Beiträge
 
Delphi 11 Alexandria
 
#12

Re: Ausgewählte Zeilen e. Stringgrid's i.e. anderes Stringg

  Alt 24. Mär 2008, 12:36
Lass mal die Abfrage der Checkboxen weg.
Markus Kinzler
  Mit Zitat antworten Zitat
aaron

Registriert seit: 18. Feb 2003
202 Beiträge
 
Delphi 2007 Professional
 
#13

Re: Ausgewählte Zeilen e. Stringgrid's i.e. anderes Stringg

  Alt 24. Mär 2008, 12:42
Dann wird immer noch eine Zeile angezeigt.
  Mit Zitat antworten Zitat
mkinzler
(Moderator)

Registriert seit: 9. Dez 2005
Ort: Heilbronn
39.851 Beiträge
 
Delphi 11 Alexandria
 
#14

Re: Ausgewählte Zeilen e. Stringgrid's i.e. anderes Stringg

  Alt 24. Mär 2008, 12:48
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.
Miniaturansicht angehängter Grafiken
sg_116.png  
Markus Kinzler
  Mit Zitat antworten Zitat
aaron

Registriert seit: 18. Feb 2003
202 Beiträge
 
Delphi 2007 Professional
 
#15

Re: Ausgewählte Zeilen e. Stringgrid's i.e. anderes Stringg

  Alt 24. Mär 2008, 12:58
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)
Miniaturansicht angehängter Grafiken
beispiel2_197.jpg  
  Mit Zitat antworten Zitat
aaron

Registriert seit: 18. Feb 2003
202 Beiträge
 
Delphi 2007 Professional
 
#16

Re: Ausgewählte Zeilen e. Stringgrid's i.e. anderes Stringg

  Alt 24. Mär 2008, 13:15
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;
  Mit Zitat antworten Zitat
aaron

Registriert seit: 18. Feb 2003
202 Beiträge
 
Delphi 2007 Professional
 
#17

Re: Ausgewählte Zeilen e. Stringgrid's i.e. anderes Stringg

  Alt 24. Mär 2008, 13:24
So komme ich nun auch ans Ziel, obwohl ich ja gerne gewußt hätte was ich falsch mache:
Delphi-Quellcode:
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;
Freundliche Grüße
Aaron
  Mit Zitat antworten Zitat
mkinzler
(Moderator)

Registriert seit: 9. Dez 2005
Ort: Heilbronn
39.851 Beiträge
 
Delphi 11 Alexandria
 
#18

Re: Ausgewählte Zeilen e. Stringgrid's i.e. anderes Stringg

  Alt 24. Mär 2008, 13:25
Ich kenne die TMS-Komponente leider nicht.
Markus Kinzler
  Mit Zitat antworten Zitat
aaron

Registriert seit: 18. Feb 2003
202 Beiträge
 
Delphi 2007 Professional
 
#19

Re: Ausgewählte Zeilen e. Stringgrid's i.e. anderes Stringg

  Alt 24. Mär 2008, 13:51
Die sind echt gut, erleichtern "manchmal" die Arbeit.
Ich möchte mich für deine Hilfe nochmal bei dir bedanken.
Gruß
Aaron
  Mit Zitat antworten Zitat
mkinzler
(Moderator)

Registriert seit: 9. Dez 2005
Ort: Heilbronn
39.851 Beiträge
 
Delphi 11 Alexandria
 
#20

Re: Ausgewählte Zeilen e. Stringgrid's i.e. anderes Stringg

  Alt 24. Mär 2008, 13:52
Ich werde mir mal die Demoversion herunterladen.
Könntest du mir dein Testprojekt mal einstellen?
Markus Kinzler
  Mit Zitat antworten Zitat
Themen-Optionen Thema durchsuchen
Thema durchsuchen:

Erweiterte Suche
Ansicht

Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 02:27 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz