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.

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

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.

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.

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

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

label1.Tag = "Something here";
string s = label1.Tag.ToString();

but it isn't displayed on the UI so the user never sees it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.