Autor Beitrag
Weide
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 61



BeitragVerfasst: Mi 05.05.04 19:12 
Hallo,

ich erstelle zur Laufzeit einige Komponenten:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
var
  FormDialog: TFormDialog;
  MyEdit: TEdit;
  MyLabel: TLabel;
  MyCombo: TComboBox;

implementation

.
.
.
.

procedure TFormDialog.ErstelleEdits(Name: String;Editor: String;
                        Hoehe: Integer; Breite: Integer;Links: Integer; Oben: Integer);
  with MyCombo do
  begin
    MyCombo := TComboBox.Create(self);
//    MyCombo := TComboBox.Create(FormDialog);
    Parent := FormDialog;
    Name   := 'ComboTyp2';
    Height := Hoehe;
    Width  := Breite;
    Left   := Links;
    Top    := Oben;
  end;




Das Füllen der komponenten mit Werten funktioniert noch einwandfrei.
Nun möchte ich die erstellten Komponenten aber natürlich auch abfragen und das
haut überhaupt nicht hin:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
.
.
.
      MyCombo := TComboBox(FormDialog.FindComponent('ComboTyp2'));
      Test := MyCombo.Text;



wenn ich folgendes mache, überspringt er die Zeile, findet also nichts:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
var 
    Edit: TComponent;
    Text: String;
begin
.
.
.
    Edit := FormDialog.FindComponent('ComboTyp2');
    If Assigned (Edit)  then
     Text := (Edit as TComboBox).Text;



Was mache ich bloß falsch? Ich bin schon ganz verzweifelt :shock:

Viele Grüße

Weide

Moderiert von user profile iconMotzi: Code- durch Delphi-Tags ersetzt.
jjturbo
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 516

Win2000 prof., WinXP prof.
D4 Stand., D5 Prof, D7 Prof, D2007 Prof.
BeitragVerfasst: Mi 05.05.04 20:40 
Hi,
versuchs mal so:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
var
    Edit: TComboBox;
    Text: String;
begin

    Edit := Form1.FindComponent('ComboTyp2') as TComboBox;
    If Assigned (Edit)  then
     Text := (Edit as TComboBox).Text;

end;


Gruß, jjturbo

_________________
Windows XP: Für die einen nur ein Betriebssystem - für die anderen der längste Virus der Welt...
Weide Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 61



BeitragVerfasst: Mi 05.05.04 20:58 
Hallo jjturbo,

das klappt leider auch nicht :(

Gruß Weide
jjturbo
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 516

Win2000 prof., WinXP prof.
D4 Stand., D5 Prof, D7 Prof, D2007 Prof.
BeitragVerfasst: Do 06.05.04 06:33 
und wenn Du beim Debuggen einen Haltpunkt auf Text:=... setzt? Wird die Zeile jetzt durchlaufen?
Hast Du auch die Änderung in der Variablendeklaration beachtet?
Habs grad bei mir ausprobiert, da geht es nämlich.

Gruß, jjturbo

_________________
Windows XP: Für die einen nur ein Betriebssystem - für die anderen der längste Virus der Welt...
Weide Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 61



BeitragVerfasst: Do 06.05.04 11:54 
Hallo jjturbo,

die Zeile wird nicht durchlaufen, die Änderung in der Varialbendeklaration habe ich beachtet - ich bin leider immer noch nicht weiter gekommen.

Gruß Weide
Weide Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 61



BeitragVerfasst: Do 06.05.04 12:23 
arrgh, ich hab's,

ich habe ja eine procedure zum erstellen der Komponenten geschrieben und übergebe auch den Komponentennamen. Diese Übergabevariable habe ich "Name" genannt.

ausblenden Quelltext
1:
2:
3:
with Mylabel do
begin
  Name := Name;


der hat sich damit irgendwie selbst benannt und somit konnte er auch später den eigentlich übergebenen Namen nicht finden.

Ich bin ein Volltrottel :x

Trotzdem vielen Dank

Gruß Weide
jjturbo
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 516

Win2000 prof., WinXP prof.
D4 Stand., D5 Prof, D7 Prof, D2007 Prof.
BeitragVerfasst: Do 06.05.04 12:24 
...und der Name der Komponente ist wirklich richtig gechrieben? (Groß-/Kleinschreibung)

_________________
Windows XP: Für die einen nur ein Betriebssystem - für die anderen der längste Virus der Welt...