Resolved Problem with a label control on Visual Studio

357mag

Well-known member
Joined
Mar 31, 2023
Messages
58
Programming Experience
3-5
Visual Studio is acting weird. I'm making a program where the user enters his first name and then clicks the Show Greeting button and I want the message to show:

Welcome to C# Programming Tim!

I've successfully added all my controls except when I added the label control that will hold the message, Visual Studio is acting weird with it.

When I try to resize it and let go of the mouse it simply disappears. Or else I can't resize it to make it as long as it needs to be.

I don't know what is going on, shouldn't be this hard to resize a label control.

I've enclosed a screenshot.
 

Attachments

  • Visual Studio Problem.jpg
    Visual Studio Problem.jpg
    101.4 KB · Views: 42
Consider that allowing the control to auto-size will ensure that it always fits whatever text it contains perfectly. By sizing it explicitly, it will be bigger than required in some cases and potentially to small in others.
 
When I create user interfaces and have labels like this I tend to put some text in it so I can see it on the designer, like "Hello John", but then in the Form Load event I clear it ready for use. This way I can see it to work with it easily and know what will go there

I also sometimes put "Hello {0}" in as the Tag and then put a code of

C#:
    greetingLabel.Text = String.Format(greetingLabel.Tag as string, nameTextNox.Text)
 
Back
Top Bottom