简体   繁体   中英

Making certain pictures visible depending on input?

If the user's input is less than 10, I want to display pic1 & if it's greater than or equal to 10, I want to display pic2. At the moment both Visible properties of pic1 and pic2 are set to false to hide them from the user before the input is entered.

My following code doesn't seem to work:

        if (userInput < 10)
        {
            pic1.Visible = true;
        }
        else
        {
            pic2.Visible = true;
        }

Should I even be using the visible property?

What about this simple code?

if (userInput < 10)
{
   pic1.Visible = true;
   pic2.Visible = false;
}
else
{
   pic2.Visible = true;
   pic1.Visible = false;
}

UPDATE
But the best solution gave you @user2864740 in comments

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM