Autor Beitrag
THF
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 110

Vista
Delphi 2005 professional
BeitragVerfasst: Do 17.02.05 10:46 
Hallo,

wie kann ich die Eigenschaften von mehreren Objekten gleichzeitig verändern.
Zum Beispiel ,wenn ich 20 Label habe und bei allen die Eigenschaft

label 1,2,3,4,5...20: enabled:= true oder enabled:=false;

setzen möchte.
Bitte Code angeben.
Gruß

THF
:twisted:
jasocul
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 6395
Erhaltene Danke: 149

Windows 7 + Windows 10
Sydney Prof + CE
BeitragVerfasst: Do 17.02.05 10:48 
Im Source mit einer Schleife.
Das Prinzip kannst du in hier gut nachvollziehen.
Im OI mittels MultiSelect.
THF Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 110

Vista
Delphi 2005 professional
BeitragVerfasst: Do 17.02.05 11:07 
Hallo,
wie geht das mit der Schleife?
Bitte Code
Gruß
THF
jasocul
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 6395
Erhaltene Danke: 149

Windows 7 + Windows 10
Sydney Prof + CE
BeitragVerfasst: Do 17.02.05 11:11 
Ungetestet:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
var
  i : Integer;
begin
  for i := 0 to Form1.ComponentCount - 1 do
  begin
    if Form1.Components[i] is TLabel then
      TLabel(Form1.Components[i]).Enabled := True; // oder False. Was du gerade willst.
  end;
end;
THF Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 110

Vista
Delphi 2005 professional
BeitragVerfasst: Do 17.02.05 11:37 
Hallo,

wenn ich eine neue Klasse deklariere.
Meinst Du das geht ?

z.b.
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:
27:
28:
29:
type
TFelder =(Label1,Label2);

  TForm1 = class(TForm)

   Label1: TLabel;
    Label2: TLabel;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);

  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var Felder: TFelder;
begin
 Felder.enabled:= false;
end;
end.


Gruß
THF

Moderiert von user profile iconChristian S.: Code- durch Delphi-Tags ersetzt.
jasocul
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 6395
Erhaltene Danke: 149

Windows 7 + Windows 10
Sydney Prof + CE
BeitragVerfasst: Do 17.02.05 11:48 
Nein.
OneOfTen
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Do 17.02.05 12:00 
ich mach das so ähnlich wie jasocul:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
var lab: Array[1..20] Of TLabel;
begin
  For n := 1 To 20 Do
    Begin
      lab[n] := FindComponent('Label'+IntToStr(n)) As TLabel;
      // ab hier kannste alles mit der Variablen machen als wäre es in Label
      lab[n].Visible := False;
      lab[n].Enabled := True;
    End;
end;