Autor Beitrag
Cix6
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 60

Windows XP
Delphi 4 Standard, Delphi 7 PE, Delphi 2005 PE
BeitragVerfasst: Fr 16.12.05 16:17 
Hi,


ich hab z.B. 50 Buttons. Wie kann ich diese jetzt mit einer schleife am besten durchgehen um alle auf Visible := False zu setzen?

Cix6


Moderiert von user profile iconraziel: Topic aus Sonstiges verschoben am Sa 17.12.2005 um 16:07
Lake
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 78


D6 prof., Delphi 10.2 Tokyo
BeitragVerfasst: Fr 16.12.05 16:27 
Also ich mache das so:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
for i := Form1.ComponentCount - 1 downto 0 do
begin
  FoundComponent := Form1.Components[i];
  if FoundComponent.ClassName  = 'TButton' then
    (FoundComponent as TButton).visible := false;
end;
Cix6 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 60

Windows XP
Delphi 4 Standard, Delphi 7 PE, Delphi 2005 PE
BeitragVerfasst: Fr 16.12.05 16:29 
und was ist form.componentcount?
alzaimar
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2889
Erhaltene Danke: 13

W2000, XP
D6E, BDS2006A, DevExpress
BeitragVerfasst: Fr 16.12.05 16:33 
Schonmal die Delphi Online-Hilfe benutzt? Cursor auf 'ComponentCount', F1 und dann nur noch lesen.

_________________
Na denn, dann. Bis dann, denn.
Cix6 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 60

Windows XP
Delphi 4 Standard, Delphi 7 PE, Delphi 2005 PE
BeitragVerfasst: Fr 16.12.05 16:35 
nein

und was ist FoundComponent?

Moderiert von user profile iconChristian S.: Beiträge zusammengefasst
Lannes
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2352
Erhaltene Danke: 4

Win XP, 95, 3.11, IE6
D3 Prof, D4 Standard, D2005 PE, TurboDelphi, Lazarus, D2010
BeitragVerfasst: Fr 16.12.05 17:24 
Hallo,

da war wohl FindComponent gemeint :wink:

_________________
MfG Lannes
(Nichts ist nicht Nichts) and ('' <> nil ) and (Pointer('') = nil ) and (@('') <> nil )
raziel
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 2453

Arch Linux
JS (WebStorm), C#, C++/CLI, C++ (VS2013)
BeitragVerfasst: Fr 16.12.05 17:29 
Nein, damit ist schon FoundComponent gemeint und es wird wohl vom Typ TComponent sein. Ist zwar nicht nötig, aber machts übersichtlicher.

@cix6: Ein kleines bisschen Eigeninitiave sollte schon drin sein, also einfach mal auf den entsprechenden Code gehen und F1 drücken.

_________________
JSXGraph
Hux
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 171



BeitragVerfasst: Fr 16.12.05 17:34 
Keine Ahnung warum aber ich fin des hier leichter:

ausblenden Delphi-Quelltext
1:
2:
3:
for i:=1 to 50 do begin
TButton(findComponent('Button'+IntToStr(i))).Visible:=false;
end;


Der Hux
Lannes
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2352
Erhaltene Danke: 4

Win XP, 95, 3.11, IE6
D3 Prof, D4 Standard, D2005 PE, TurboDelphi, Lazarus, D2010
BeitragVerfasst: Fr 16.12.05 17:44 
Hallo,
user profile iconraziel hat folgendes geschrieben:
Nein, damit ist schon FoundComponent gemeint ...
wer lesen kann..., oh man.. :autsch:

_________________
MfG Lannes
(Nichts ist nicht Nichts) and ('' <> nil ) and (Pointer('') = nil ) and (@('') <> nil )
Lake
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 78


D6 prof., Delphi 10.2 Tokyo
BeitragVerfasst: Fr 16.12.05 17:57 
Hallo,

user profile iconraziel hat folgendes geschrieben:
Nein, damit ist schon FoundComponent gemeint....

Richtig, ich hätte vielleicht eine andere Bezeichnung wählen sollen.
ausblenden Delphi-Quelltext
1:
2:
var:
  FoundComponent : TComponent;


user profile iconHux hat folgendes geschrieben:
Keine Ahnung warum aber ich fin des hier leichter:

Ich verwende deswegen das Andere, weil es egal ist wieviele Buttons auf dem Form sind und wie diese heissen.
alzaimar
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2889
Erhaltene Danke: 13

W2000, XP
D6E, BDS2006A, DevExpress
BeitragVerfasst: Fr 16.12.05 19:04 
user profile iconLake hat folgendes geschrieben:
user profile iconHux hat folgendes geschrieben:
Keine Ahnung warum aber ich fin des hier leichter:

Ich verwende deswegen das Andere, weil es egal ist wieviele Buttons auf dem Form sind und wie diese heissen.

Eben. Man sollte die Verwendung von FindComponent unter Strafe stellen :wink:

_________________
Na denn, dann. Bis dann, denn.


Zuletzt bearbeitet von alzaimar am Fr 16.12.05 20:18, insgesamt 1-mal bearbeitet
raziel
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 2453

Arch Linux
JS (WebStorm), C#, C++/CLI, C++ (VS2013)
BeitragVerfasst: Fr 16.12.05 20:06 
Und falls es auch mal alles sein soll, was eine Eigenschaft Visible besitzt, empfehle ich diesen meinen Beitrag aus der Delphi-Library ;)

_________________
JSXGraph