How to check if a label is visible?This is not working...

   if(labelFS.Visible = false)
        {do sth}
   else//labelFS.Visible = true
        {do other}

solved

有帮助吗?

解决方案

Use == to compare two values, not the assignment operator (a single =).

By using a single =, you're actually setting the value of labelFS.Visible to False, which hides it.

(There's also no need to type out true and false .)

if (labelFS.Visible)
    // do something
else
    // do something else

I'd suggest reading up on the difference. Here's a start...

其他提示

if(labelFS.Visible == false)
        {do sth}
   else//labelFS.Visible == true
        {do other}

Use == instead of =

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top