Autor Beitrag
MisterBum83
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 245
Erhaltene Danke: 2

WIN XP
Delphi 6
BeitragVerfasst: Mi 27.09.06 15:24 
Hallo,
wie schaffe ich es, alle Edits, die einen bestimmten Tag-Wert haben, zu Enabled?

Hier mein Code, der leider nicht ganz funktioniert. Er stürzt an der Stelle TEdit.... ab!!!

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
if CheckBox1.Checked = true then
  begin
    for i := 1 to 301 do
    begin
      TEdit(FindComponent('MF_Edit' + IntToStr(i)).Tag = 1).Enabled := false;
    end;
  end
  else
  begin
    for i := 1 to 301 do
    begin
      TEdit(FindComponent('MF_Edit' + IntToStr(i)).Tag = 1).Enabled := true;
    end;
  end;
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Mi 27.09.06 15:26 
Moin!

Du mußt das .Tag = 1 in einer if-Abfrage vorher separat prüfen. ;)

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
MisterBum83 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 245
Erhaltene Danke: 2

WIN XP
Delphi 6
BeitragVerfasst: Mi 27.09.06 15:31 
Ich stehe gerade voll auf dem Schlauch. Kannst du mal grade am Quellcode zeigen wie???
Danke!!!
freak4fun
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 604
Erhaltene Danke: 4

Win 7 Pro
VS 2013 Express, Delphi, C#, PHP, Java
BeitragVerfasst: Mi 27.09.06 15:36 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
for i := 1 to 301 do
  begin
    EditComp := TEdit(FindComponent('MF_Edit' + IntToStr(i)));
    EditComp.Enabled := (not CheckBox1.Checked) and (EditComp.Tag = 1);

end;

Ungetestet.

MfG
freak

_________________
"Ich werde auf GAR KEINEN Fall…!" - "Keks?" - "Okay, ich tu's."
i++; // zaehler i um 1 erhoehen


Zuletzt bearbeitet von freak4fun am Mi 27.09.06 15:47, insgesamt 1-mal bearbeitet
jakobwenzel
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1889
Erhaltene Danke: 1

XP home, ubuntu
BDS 2006 Prof
BeitragVerfasst: Mi 27.09.06 15:37 
Ich würds so machen:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
if CheckBox1.Checked = true then
  begin
    for i := 1 to 301 do
    begin
      comp:=FindComponent('MF_Edit' + IntToStr(i));
      if comp.tag=1 then
        TEdit(comp).Enabled := false;
    end;
  end
  else
  begin
    for i := 1 to 301 do
    begin
      comp:=FindComponent('MF_Edit' + IntToStr(i));
      if comp.tag=1 then
        TEdit(comp).Enabled := true;
    end;
  end;

_________________
I thought what I'd do was, I'd pretend I was one of those deaf-mutes.
MisterBum83 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 245
Erhaltene Danke: 2

WIN XP
Delphi 6
BeitragVerfasst: Mi 27.09.06 15:38 
Danke an alle:

Hier meine Lösung:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
if CheckBox1.Checked = true then
  begin
    for i := 1 to 301 do
    begin
    if TEdit(FindComponent('MF_Edit' + IntToStr(i))).Tag = 1 then
      TEdit(FindComponent('MF_Edit' + IntToStr(i))).Enabled := false;
    end;
  end
  else
  begin
     for i := 1 to 301 do
    begin
    if TEdit(FindComponent('MF_Edit' + IntToStr(i))).Tag = 1 then
      TEdit(FindComponent('MF_Edit' + IntToStr(i))).Enabled := true;
    end;
  end;
jakobwenzel
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1889
Erhaltene Danke: 1

XP home, ubuntu
BDS 2006 Prof
BeitragVerfasst: Mi 27.09.06 15:41 
Deine Lösung wird langsamer laufen als meine, da pro Schleifendurchlauf FindComponent 2 mal aufgerufen wird, bei meinem COde nur einmal.

_________________
I thought what I'd do was, I'd pretend I was one of those deaf-mutes.
freak4fun
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 604
Erhaltene Danke: 4

Win 7 Pro
VS 2013 Express, Delphi, C#, PHP, Java
BeitragVerfasst: Mi 27.09.06 15:45 
user profile iconjakobwenzel hat folgendes geschrieben:
Deine Lösung wird langsamer laufen als meine, da pro Schleifendurchlauf FindComponent 2 mal aufgerufen wird, bei meinem COde nur einmal.


Kannst du zu meiner Lösung auch was sagen, bis auf das sie noch falsch ist?

MfG
freak

_________________
"Ich werde auf GAR KEINEN Fall…!" - "Keks?" - "Okay, ich tu's."
i++; // zaehler i um 1 erhoehen
jakobwenzel
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1889
Erhaltene Danke: 1

XP home, ubuntu
BDS 2006 Prof
BeitragVerfasst: Mi 27.09.06 15:48 
Das sie falsch ist, hab ich nicht gesagt.
Nur durch den 2 maligen Aufruf von FindCOmponent etwas ineffizient.

_________________
I thought what I'd do was, I'd pretend I was one of those deaf-mutes.
freak4fun
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 604
Erhaltene Danke: 4

Win 7 Pro
VS 2013 Express, Delphi, C#, PHP, Java
BeitragVerfasst: Mi 27.09.06 15:50 
user profile iconjakobwenzel hat folgendes geschrieben:
Das sie falsch ist, hab ich nicht gesagt.
Nur durch den 2 maligen Aufruf von FindCOmponent etwas ineffizient.


Achso, deine Aussage bezog sich auf meine Lösung? Ich hab es jetzt mal geändert. :mrgreen:

MfG
freak

_________________
"Ich werde auf GAR KEINEN Fall…!" - "Keks?" - "Okay, ich tu's."
i++; // zaehler i um 1 erhoehen
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Mi 27.09.06 16:24 
Moin!

Was ist denn, wenn FindComponent() NIL liefert?! :? Ich würde da noch eine if-Kapsel drum machen. ;)

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.