Autor Beitrag
Travis
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 48



BeitragVerfasst: Mi 26.03.03 19:22 
Hallo zusammen,

wie kann ich auf mehrere Objekte des gleichen Typs gleichzeitig zugreifen? Ich habe auf meinem Formular 3 StringGrids die genau gleich aufgebaut sind. Jetzt möchte ich die Überschriften (FixedCol) in allen drei StringGrids gleichzeitig ändern. Habe folgendes versucht, dass funktionierte aber leider nicht:

ausblenden Quelltext
1:
2:
3:
  with TStringGrid do
    Cells[0,0] := 'Name';
    {usw...}

Hat jemand von euch vielleicht eine Idee?

Schon im Voraus danke,

Travis
AndyB
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1173
Erhaltene Danke: 14


RAD Studio XE2
BeitragVerfasst: Mi 26.03.03 19:45 
Das geht nicht direkt. Du musst entweder alles dreifach schreiben, oder du legst z.B. ein Array[0..2] of TStringGrid an, dessen Elemente du in Form-OnCreate auf die 3 Grids setzt. Danach kannst du immer mit einer Schleife deine Zuweisungen machen.

ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
...
private
  FStringGrids: array[0..2] of TStringGrid;
end;

...

procedure TForm1.FormCreate(...)
begin
  FStringGrid[0] := StringGrid1;
  FStringGrid[1] := StringGrid1;
  FStringGrid[2] := StringGrid1;
end;

procedure TForm1. ...
begin
  for i := 0 to High(StringGrids) do
    FStringGrids[i].Cells[0, 0] := 'Text';
end;

_________________
Ist Zeit wirklich Geld?
Travis Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 48



BeitragVerfasst: Mi 26.03.03 19:49 
Danke für die Antwort!
Das werde ich mal ausprobieren...

Travis