Autor Beitrag
Kroni
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 720

Win 98, Win ME, Win2k, Win XP
D3 Pro
BeitragVerfasst: Sa 12.02.05 17:30 
Hallo, haber mir zwar schon so ziemlich alle suchergebnisse für create; durchgelesen, aber ihc bekomms immer noch nicht hin
FOlgendes:
Ich würde gerne bei Laufzeit einen TStringGrid erzeugen, die Eigenschaften eintragen und dann anzeigen lassen.
Habe es einfach mal zum ausprobieren so versucht:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
procedure TForm1.Button1Click(Sender: TObject);
 var stringgrid1:TObject;
begin

stringgrid1:=TStringgrid.create;
end;

das Funktioniert aber nicht, wegen undefinierter Bezeichner....
Ich habe leider noch nicht so die Erfahrung mit Create und sowas alles....
Wäre trotzdem um eine Antwort dankbar.....
Gruß, Kroni
retnyg
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2754

SNES, GB, GBA, CPC, A500, 486/66, P4/3.0HT: NintendOS, AmigaOS, DoS
Delphi 5, Delphi 7
BeitragVerfasst: Sa 12.02.05 17:33 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
procedure TForm1.Button1Click(Sender: TObject);
 var stringgrid1:TStringgrid;
begin

  stringgrid1:=TStringgrid.create(Form1);
  stringgrid1.parent := form1;

end;


probiers mal so
Sprint
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 849



BeitragVerfasst: Sa 12.02.05 17:44 
Wenn du ein TStringGrid zur Laufzeit erstellen willst, dann musst du auf jeden Fall die Unit Grids mit einbinden.
ausblenden Delphi-Quelltext
1:
uses Grids;					

Soll nach der Erstellung von TStringGrid auch noch drauf zugegriffen werden können, dann würde ich eine Feldvariable in deiner Form anlegen.
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
type
  TForm1 = class(TForm)
  ...
  private
    { Private-Deklarationen }
    StringGrid: TStringGrid;
  public
  ...
  end;

Und dann so erstellen:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
procedure TForm1.FormCreate(Sender: TObject);
begin

  StringGrid := TStringGrid.Create(Self);
  with StringGrid do
  begin
    Parent := Self;
    SetBounds(1010, Self.ClientWidth - 20, Self.ClientHeight - 20);
    Visible := True;
  end;

end;

Wenn du jetzt schon weißt, das du nicht wieder auf TStringGrid zugreifen wirst, dann kannst du es auch so machen:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
procedure TForm1.FormCreate(Sender: TObject);
begin

  with TStringGrid.Create(Self) do
  begin
    Parent := Self;
    SetBounds(1010, Self.ClientWidth - 20, Self.ClientHeight - 20);
    Visible := True;
  end;

end;



Edit: \\ Beim letzten Beispiel kannst du dann natürlich auf die Feldvariable verzichten.

_________________
Ciao, Sprint.
Kroni Threadstarter
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 720

Win 98, Win ME, Win2k, Win XP
D3 Pro
BeitragVerfasst: Sa 12.02.05 18:33 
Ich seh das schon, ich müsste mich mit der Theamtik der Objekte usw. mal ein bisschen ausführlicher beschäftigen.
Danke an euch beide, es funktioniert nun!
=)