Home > Mobile >  In csharp, I want the button to appear whenever I want and disappear whenever I want
In csharp, I want the button to appear whenever I want and disappear whenever I want

Time:12-13

I tried this way, but the button does not appear even though the items are larger than 0.

enter image description here

How can I do this?

CodePudding user response:

It's not enough to set it to false if you don't want it to show. You also need to set it to true when you want to see it again. But you can write one line that does both:

btnRemoveToCart.Visible = (lbxCart.Items.Count > 0);

Now we also no longer need the if() check.

CodePudding user response:

Try add

else
{
    btnRemoveToCart.Visible = true;
}
  • Related