سؤال

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