AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

StringGrid nach StrigGrid

Ein Thema von publes · begonnen am 24. Feb 2005 · letzter Beitrag vom 24. Feb 2005
Antwort Antwort
publes

Registriert seit: 3. Jan 2005
26 Beiträge
 
Delphi 6 Enterprise
 
#1

StringGrid nach StrigGrid

  Alt 24. Feb 2005, 05:25
Wie kopiere ich in zwei unterschiedlichen Form's ein Grid in ein anderes Grid..........
beide heißen StringGrid2, das eine in der Form1 und das andere in der Form 2.........
Jeder fängt mal klein an........ und will dann hoch hinaus!!!
  Mit Zitat antworten Zitat
Benutzerbild von Binärbaum
Binärbaum

Registriert seit: 19. Jan 2005
Ort: Elstra
764 Beiträge
 
Delphi 7 Enterprise
 
#2

Re: StringGrid nach StrigGrid

  Alt 24. Feb 2005, 06:42
In etwa so:
Delphi-Quellcode:
var i, j: Integer;
begin
  Form2.StringGrid2.ColCount:= Form1.StringGrid2.ColCount;
  Form2.StringGrid2.RowCount:= Form1.StringGrid2.RowCount;
  for i:=0 to Form1.StringGrid2.ColCount-1 do
   for j:=0 to Form1.StringGrid2.RowCount-1 do
     Form2.StringGrid2.Cells[i,j]:= Form1.StringGrid2.Cells[i,j];
end;
MfG
Binärbaum
There are exactly 10 kinds of people: those who understand binary, and those who don't.
---
"Software reift beim Kunden. Bei Hardware ist es anders: Hardware fault beim Kunden." - Rainer G. Spallek
  Mit Zitat antworten Zitat
Benutzerbild von Sharky
Sharky

Registriert seit: 29. Mai 2002
Ort: Frankfurt
8.251 Beiträge
 
Delphi 2006 Professional
 
#3

Re: StringGrid nach StrigGrid

  Alt 24. Feb 2005, 06:59
Hai Binärbaum,

das ganze müsste auch mit einer Schleife gehen

Delphi-Quellcode:
procedure TForm1.Button1Click(Sender: TObject);
var
  ndx : Integer;
begin
  Form2.StringGrid2.ColCount:= Form1.StringGrid2.ColCount;
  Form2.StringGrid2.RowCount:= Form1.StringGrid2.RowCount;

  for ndx := 0 to StringGrid1.RowCount do
  begin
    Form2.StringGrid1.Rows[ndx] := Form1.StringGrid1.Rows[ndx];
  end;
end;
Stephan B.
"Lasst den Gänsen ihre Füßchen"
  Mit Zitat antworten Zitat
Benutzerbild von Binärbaum
Binärbaum

Registriert seit: 19. Jan 2005
Ort: Elstra
764 Beiträge
 
Delphi 7 Enterprise
 
#4

Re: StringGrid nach StrigGrid

  Alt 24. Feb 2005, 14:44
Zitat von Sharky:
Hai Binärbaum,

das ganze müsste auch mit einer Schleife gehen

Delphi-Quellcode:
procedure TForm1.Button1Click(Sender: TObject);
var
  ndx : Integer;
begin
  Form2.StringGrid2.ColCount:= Form1.StringGrid2.ColCount;
  Form2.StringGrid2.RowCount:= Form1.StringGrid2.RowCount;

  for ndx := 0 to StringGrid1.RowCount do
  begin
    Form2.StringGrid1.Rows[ndx] := Form1.StringGrid1.Rows[ndx];
  end;
end;
War mir fast schon klar, dass da jemand eine einfachere/ bessere Lösung hat. Die Frage ist nur, ob dieser Code auch wirklich schneller ist, da Rows ja auch auf die einzelnen Felder einer Zeile zugreifen muss, oder nicht?
There are exactly 10 kinds of people: those who understand binary, and those who don't.
---
"Software reift beim Kunden. Bei Hardware ist es anders: Hardware fault beim Kunden." - Rainer G. Spallek
  Mit Zitat antworten Zitat
Benutzerbild von Jasocul
Jasocul

Registriert seit: 22. Sep 2004
Ort: Delmenhorst
1.337 Beiträge
 
Delphi 11 Alexandria
 
#5

Re: StringGrid nach StrigGrid

  Alt 24. Feb 2005, 14:55
imho werden da Speicherbereiche kopiert. Rows ist vom Typ TStrings. Daher sollte das schneller sein.
Das gleiche ginge auch mit Cols. Da man meistens weniger Cols als Rows hat wäre es damit vermutlich noch schneller.
Peter
  Mit Zitat antworten Zitat
Antwort Antwort


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 06:32 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