Click here to Skip to main content
15,909,437 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have 2 labels in my winform. say 1 is passed..2nd failed..The visiblity property is set to FALSE in both the labels property tab. I have some function doing.I need to do like this..

If that function is a success, then the 1st label(passed) should be made visible.If the function is a failure then the 2nd label(failed) should be made visible.

Any help would be really appreciated..

Thanks in advance..
Posted
Comments
Sergey Alexandrovich Kryukov 7-Jun-13 1:30am    
What help?! With assigning something.Visible = true?
—SA
_Amy 7-Jun-13 2:00am    
Are you using any update panel?

Your question is totally unclear to understand.When your function is a success then make
C#
yourLabelName.Visible= true

and when your function is a failure then make it
C#
yourLabelName.Visible= false

See some examples also..
http://social.msdn.microsoft.com/Forums/en-US/winforms/thread/dfed6cbe-29ca-4e5c-b597-b9bf1b77305e[^]
http://asp-net-example.blogspot.com/2009/03/how-to-show-hide-visible-label.html[^]
 
Share this answer
 
Comments
Vysakh Venugopal 7-Jun-13 1:51am    
@ridoy: I tried that.But its not working..but no error is thrown..
lukeer 7-Jun-13 1:52am    
Actually, there are two labels with XORed visibility.
Vysakh Venugopal 7-Jun-13 1:53am    
@lukeer: How it can be cleared??how this can be achieved??
lukeer 7-Jun-13 3:12am    
If you mean to hide both labels, I updated my answer.
And please put comments referring to a solution in the comments section of that solution.
ridoy 7-Jun-13 2:14am    
boolean value=null;
when your function success make it as value=true else value=false.
Then check it later..
if(value)
yourLabel.Visibility=Visibility.Visible;
else
yourLabel.Visibility=Visibility.Collapsed;
In your form, create a method
C#
ShowOutcome(bool success)
{
    successLabel.Visible = success;
    failureLabel.Visible = !success;

    // Eventually, do some more visual stuff like changing texts or so
}
Call that method when your function knows whether it is a success or not.

[Edit]
To display neither label, you can create such a method:
C#
ClearOutcome()
{
    successLabel.Visible = failureLabel.Visible = false;
}
[/Edit]
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900