Autor Beitrag
mandawar
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 25

Win XP, Suse 9.0
3.0
BeitragVerfasst: Di 09.05.06 10:18 
Hi
also hier unten ist mein Code, aber wenn ich d.caption irgendwas zuwesiesagt der mir dass es ein unbekannter Bezeichner ist, also nimmt d irgendwie nicht die eigenschaften der komponente label an, und ich weis nicht warum...
Hat irgendwer von euch ne Idee?!
MfG Mandawar

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
procedure TForm1.CheckBoxClick(Sender: TObject);
var z,i,bytewert:byte;
    c,d:TComponent;

begin
bytewert:=0;
with (c as TLabel) do
begin
 for z:=10 to 17 do
 begin
  d:=findcomponent('Label'+IntToStr(z));
  d.Caption:='0';


Moderiert von user profile iconGausi: Code- durch Delphi-Tags ersetzt
Moderiert von user profile iconGausi: Topic aus Sonstiges (Delphi) verschoben am Di 09.05.2006 um 11:40
Jetstream
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 222



BeitragVerfasst: Di 09.05.06 10:23 
Titel: Re: dynamische Komponente nimmt die eigenschaften nicht an :
ausblenden Delphi-Quelltext
1:
with (c as TLabel) do					

meinst du da zufällig d statt c ?

Moderiert von user profile iconraziel: Code- durch Delphi-Tags ersetzt
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8554
Erhaltene Danke: 481

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Di 09.05.06 10:38 
Überleg mal, was du da versuchst (Kommentare im Code):

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
procedure TForm1.CheckBoxClick(Sender: TObject);
var z,i,bytewert:byte;
    c,d:TComponent;
// c und d sind also lokale Variablen für eine Komponente

begin
  bytewert:=0;
  with (c as TLabel) do
  // Womit soll er was tun??
  // c ist nicht initialisiert worden!!!
  begin
    for z:=10 to 17 do
    begin
      d:=findcomponent('Label'+IntToStr(z));
      // hmm.. er soll also auf dem Label C, was im übrigen nicht initialisiert wurde,
      // eine andere Label-Komponente finden. Du hast ein Label auf einem Label liegen? :gruebel:
      d.Caption:='0';
Kroko
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1284

W98 W2k WXP
Turbo D
BeitragVerfasst: Di 09.05.06 10:48 
Probiere mal das
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
procedure TForm1.CheckBoxClick(Sender: TObject);
var 
  z: Byte;
begin
 for z :=10 to 17 do
   TLabel (findcomponent('Label'+IntToStr(z))).Caption:='0';
end;

_________________
Die F1-Taste steht nicht unter Naturschutz und darf somit regelmäßig und oft benutzt werden! oder Wer lesen kann, ist klar im Vorteil!
mandawar Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 25

Win XP, Suse 9.0
3.0
BeitragVerfasst: Di 16.05.06 09:49 
und wie initialisiere ich dann c, wiel ich hab später im Quelltext noch die Stelle
if c.checked then

:(
THx in vorraus
Horschdware
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 744
Erhaltene Danke: 54

Win XP Pro, Win 7 Pro x64
Delphi 7, Delphi XE, C++ Builder 5, SAP R/3
BeitragVerfasst: Di 16.05.06 09:56 
wenn c ein label sein soll: gar nicht, da ein label keine checked eigenschaft hat.
ist c etwas anderes (z.b. eine checkbox), dann verfährst du genau so wie oben beschrieben, nur eben für die checkbox c.

z.b.
ausblenden Delphi-Quelltext
1:
2:
3:
{...}
if (TCheckBox(FindComponent('CheckBox'+IntToStr(z))).Checked) then
  DoSomething();

_________________
Delphi: XE - OS: Windows 7 Professional x64