c# - How to make button invisible? -


Created using the button 02 toolbox. Button03 Programmically created inside Method111, I am able to use the visible property of the button 03, but when I am in another method (assuming Method222), I can not use the visible property This reference Outside I say I am using C #

  Private zero method 111 () {button button = 03 = new button (); Button 03. Size = button 0. Size; Button03. Location = New point (Button 02. Space.x + Button 02. Width + A02, Button02. Location Y); Button 03. Valid = true; Button 03. Text = ""; Controls.Add (Button03); Button03.click + = (sender, args) => {}; }   

button 03 variable is local for your current function Scope This means that you can not access the variable outside of this function.

To resolve this, you need to declare a "code> button03 at some points, which can be accessed from both functions, e.g. As a class member.

I do not know why you can reach Button02 because you have not posted the code that contains the declaration. However, my assumption is that your code is something like that Looks:

  Public square SomeClass {Public Button Button 02; Private Zero Method111 () {Button Button03; // button 03 is accessible because it has been declared in this method // button 02 is reachable because it has been declared in this class} Private Zero Some other Math () {// button 03 is unavailable because it is scope of other method Has been declared in / button 02 accessible because it is declared in this class}}  

Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -