943,096 Members | Top Members by Rank

Ad:
  • C# Discussion Thread
  • Unsolved
  • Views: 1482
  • C# RSS
Mar 19th, 2010
0

Transparent text in a visible Label/Control

Expand Post »
I have a label with a picture that i want to be visible to the user. However, i also have text in that label that i need for the program to work but is unnessesary to the user.

I would use Color.Transparent; to hide the text however i have a background on the form and using transparen would just write the text in the background color of the form which would result in the user still seeing the text but just in a different color. (the background picture isn't a solid color it is checkered, furthermaking color.transparent useless)

So my question is, is there a way i can accomplish this?


If this is not possible, is there a place in the properties of a control to store any text information whichout the user seeing it.

If anyone is wondering why i need this, it is because i am dynamicly rying to retrieve which button is pressed.
Similar Threads
Reputation Points: 10
Solved Threads: 8
Junior Poster
toko is offline Offline
104 posts
since Aug 2007
Mar 19th, 2010
0
Re: Transparent text in a visible Label/Control
If I understood correctly, you'Re trying to get which button was clicked last to store it's name somewhere. You could use the Tag Property of your forms component, a property which is unseeable by the user and exists on most Windows.Forms components. If I'm not mistaken, it's type is object, so you can put anything.

Another way to do that would be to use the (object sender) part of the parameters in the event to get the sender's name like this

C# Syntax (Toggle Plain Text)
  1. invisLabel.Text = (sender as Button).Name

In that strip of code, invisLabel is a label in your form which's value is your button's name. The part in parenthesis tells the compiler that the sender (your button) is a Button, so you can get it's properties there.
Last edited by GuillaumeCantin; Mar 19th, 2010 at 9:11 pm.
Reputation Points: 10
Solved Threads: 1
Newbie Poster
GuillaumeCantin is offline Offline
4 posts
since Mar 2010
Mar 19th, 2010
0
Re: Transparent text in a visible Label/Control
I tried the .Name way but since it's a control array it doesn't return anything. When i try to display the name in a messagebox, the messagebox displays blank.
Reputation Points: 10
Solved Threads: 8
Junior Poster
toko is offline Offline
104 posts
since Aug 2007
Mar 19th, 2010
1
Re: Transparent text in a visible Label/Control
Click to Expand / Collapse  Quote originally posted by toko ...
I tried the .Name way but since it's a control array it doesn't return anything. When i try to display the name in a messagebox, the messagebox displays blank.
Have you tried using the tag property of your label? From what you said in the opening post, you wanted to use a label to store the text so it should have a Tag property
Reputation Points: 10
Solved Threads: 1
Newbie Poster
GuillaumeCantin is offline Offline
4 posts
since Mar 2010
Mar 21st, 2010
0
Re: Transparent text in a visible Label/Control
Totally agree with the use of .Tag. The tag property is for "User-defined data associated with the object".
You can access it in Code as
C# Syntax (Toggle Plain Text)
  1. label1.Tag = "Something here";
  2. string s = label1.Tag.ToString();
but it isn't displayed on the UI so the user never sees it.
Reputation Points: 512
Solved Threads: 246
Nearly a Posting Virtuoso
Ryshad is offline Offline
1,260 posts
since Aug 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C# Forum Timeline: Getting handle on main form
Next Thread in C# Forum Timeline: text file in project





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC