Autor Beitrag
Zlatan
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 175



BeitragVerfasst: Do 03.02.11 11:33 
Könnte jemand folgenden quelltext korrigieren?

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
procedure TForm1.BitBtn1Click(Sender: TObject);
begin
if Button2.Hide
then
begin
Button1.Hide;
Button2.Show;
end else if Button1.Hide
then
begin
Button2.Hide;
Button1.Show;
end
end;

end.
elundril
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3747
Erhaltene Danke: 123

Windows Vista, Ubuntu
Delphi 7 PE "Codename: Aurora", Eclipse Ganymede
BeitragVerfasst: Do 03.02.11 11:36 
Hallo,

1) Deine Quelltextformatierung macht es eher zum Quältext
2) ButtonX.Hide gibt keinen Boolean-Wert zurück, was du abfragen könntest wäre ButtonX.Visible. Mit der Methode Hide versteckst du den Button nur. ;)
3) Da anscheinend eh immer nur 1 Button von 2 sichtbar ist brauchst du die zweite If-Abfrage nicht, sondern kannst gleich nach dem else das begin schreiben. ;)

lg elundril

_________________
This Signature-Space is intentionally left blank.
Bei Beschwerden, bitte den Beschwerdebutton (gekennzeichnet mit PN) verwenden.

Für diesen Beitrag haben gedankt: Zlatan
Bergmann89
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1742
Erhaltene Danke: 72

Win7 x64, Ubuntu 11.10
Delphi 7 Personal, Lazarus/FPC 2.2.4, C, C++, C# (Visual Studio 2010), PHP, Java (Netbeans, Eclipse)
BeitragVerfasst: Do 03.02.11 11:44 
Hey,

den 3. Punkt muss er sogar machen, sonst passiert gar nix:
ausblenden Quelltext
1:
2:
3:
4:
5:
wenn Button1 sichtbar, dann..
  blende Button1 aus
  mache Button2 sichtbar
ansonsten: wenn Button2 sichtbar --> wird immer True 
...


MfG Bergmann

_________________
Ich weiß nicht viel, lern aber dafür umso schneller^^
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Do 03.02.11 11:45 
Also ganz ohne If ;-)
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
procedure TForm1.BitBtn1Click(Sender: TObject);
begin
    Button1.Visible := not Button1.Visible;
    Button2.Visible := not Button1.Visible;
end.

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.

Für diesen Beitrag haben gedankt: elundril