Autor Beitrag
link2004
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 17



BeitragVerfasst: Sa 09.04.11 20:31 
Wie der Titel schon verrät möchte ich gerne wissen ob es möglich ist wenn jetzt meine Variable (z) den Wert 4 erreicht dass ein Button von Unsichtbar auf sichtbar wechseld und wenn es den Wert 4 überschreitet das es von sichtbar auf unsichtbar wechseld.
Danke im Vorraus


Zuletzt bearbeitet von link2004 am So 10.04.11 10:30, insgesamt 1-mal bearbeitet
m-s
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 149
Erhaltene Danke: 7

Win 10
C# (VS 2015)
BeitragVerfasst: Sa 09.04.11 20:45 
Du musst prüfen ob die Variable den Wert 4 hat und dann den button auf enable setzen.

ausblenden C#-Quelltext
1:
2:
if (variable != 4)
    button1.Enabled = false;

So wird der Button nur sichtbar wenn die Varible 4 hat. Ist der Wert kleiner oder größer ist er unsichtbar.

_________________
Gruß Markus

Für diesen Beitrag haben gedankt: link2004
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19346
Erhaltene Danke: 1754

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Sa 09.04.11 21:17 
Nein, aktiviert wird er bei dir ja nicht mehr. ;-)
Und die Sichtbarkeit wird gar nicht geändert.
ausblenden C#-Quelltext
1:
yourButton.Visible = yourVariable == 4;					
m-s
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 149
Erhaltene Danke: 7

Win 10
C# (VS 2015)
BeitragVerfasst: Sa 09.04.11 21:24 
user profile iconjaenicke hat folgendes geschrieben Zum zitierten Posting springen:
Nein, aktiviert wird er bei dir ja nicht mehr. ;-)
Und die Sichtbarkeit wird gar nicht geändert.
ausblenden C#-Quelltext
1:
yourButton.Visible = yourVariable == 4;					

Ach herjee, jetzt wo Dus sagst. habe ich ja völlig daneben gelegen.
Vielleicht sollte ich meine Ratschläge doch besser testen :)

So müsste es doch auch gehen und für einen Anfänger, wie mich, einfacher zu verstehen sein oder ist das wieder falsch?
ausblenden C#-Quelltext
1:
2:
3:
4:
            if (yourvariable == 4)
                button1.Visible = true;
            else if ((yourvariable < 4) || (yourvariable > 4))
                button1.Visible = false;

_________________
Gruß Markus
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19346
Erhaltene Danke: 1754

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Sa 09.04.11 21:44 
Das ist zwar unnötig lang, sollte aber funktionieren und das gleiche machen, ja. ;-)
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: So 10.04.11 09:29 
Zumindest die zweite if-Abfrage kann man aber auch als Anfänger weglassen, denn das "else" der ersten erledigt schon alles, was man da braucht ;-)

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".