Autor Beitrag
JayK
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1013



BeitragVerfasst: Sa 05.11.05 15:06 
Hi,
ich hab mehrere JvGradients aufm Form und die möchte ich durch ein Array ansprechen können.
Ich hab folgendes gemacht:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
type
  TMainForm = class (TForm)
  ...
  g1: TJvGradient;
  ...
  end;

var
  Gradient: array of TComponent;

implementation

procedure TMainForm.FormShow(Sender: TObject);
begin
  Gradient[0] := g1;
end;

Aber bei Gradient[0] := ... gibt es eine AV 'Schreiben von Adresse 00000000' :?
Mit Gradient: array of TJvGradient geht's auch nich und mit Gradient[0] := TJvGradient.Crate(self); vor der Zuweisung erst recht nich :nixweiss:

Was kann ich machen, damit das funktioniert?
Fabian W.
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1766

Win 7
D7 PE
BeitragVerfasst: Sa 05.11.05 16:15 
Ja wie, du musst die Kompos ja auch aus dem Array erstellen array[1] := Kompo.create ansonsten hilft dir der Befehl FindComponent weiter.
Alstar
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 827



BeitragVerfasst: Sa 05.11.05 16:17 
Du musst dem Array mit SetLength(<Array>, <Länge>); den nötigen Speicher reservieren. Erst dann kannst Du die Komponenten erzeugen

Alstar
Fabian W.
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1766

Win 7
D7 PE
BeitragVerfasst: Sa 05.11.05 16:19 
Ich glaube er hat sie schon auf der Form, möchte jetzt aber nur übern String (mit dem Namen der Kompo) drauf zu greifen: FindComponent.

Ansonsten wie gesagt dynamisch erzeugen... und dann per array zugreifen
JayK Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1013



BeitragVerfasst: Sa 05.11.05 16:24 
@Fabian: Ich brauch das Ding zur Designzeit und einen Namen zum übergeben hat es ja, den brauch ich nicht erst suchen ;)

Aber SetLength war das Problem, hatte ich mal wieder vergessen :autsch: Danke an euch beide.