Results 1 to 7 of 7

Thread: [RESOLVED] label control has no handles to resize on form at design time, how to give it them?

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2024
    Posts
    874

    Resolved [RESOLVED] label control has no handles to resize on form at design time, how to give it them?

    Simply I drop label on form and cannot size it unless going into property pages for the label.

    Other controls do have handles to drag bigger or smaller.

    And an imported vb6 program, the labels are resizable as shown in vbnet designer.

    pics to show this. I know it is basic stuff, but here eluding me.
    Attached Images Attached Images    

  2. #2
    Hyperactive Member
    Join Date
    Jul 2022
    Location
    Buford, Ga USA
    Posts
    488

    Re: label control has no handles to resize on form at design time, how to give it the

    is auto-size set to true??

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,978

    Re: label control has no handles to resize on form at design time, how to give it the

    If the AutoSize property is True, which it is by default for a Label, you can't resize manually.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  4. #4

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2024
    Posts
    874

    Re: label control has no handles to resize on form at design time, how to give it the

    Thanks guys, I just got back and checked and it is set to auto size = True
    Set to false and can be resized.

    Odd, the VS when you place a Label control on the form, it defaults to auto size is true, is that normal?

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2024
    Posts
    874

    Re: label control has no handles to resize on form at design time, how to give it the

    And can the label transparency be set to allow an image in the Picture box control shine through the label?
    As you see in that pic with the flowers, the label shows a big gray box.

    The full form Picturebox control is set behind, and Label controls are in front.

    I also have smaller picture boxes under a few of the yellow labels.
    The ones on the far left and at the bottom.

    I forget why I did that in vb6, but it all was transparent without any particular effort in the designer window.
    Likely was using it to frame those labels and give it the appearance of depth.
    Last edited by sdowney1; Apr 20th, 2024 at 03:28 PM.

  6. #6
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,978

    Re: label control has no handles to resize on form at design time, how to give it the

    Quote Originally Posted by sdowney1 View Post
    when you place a Label control on the form, it defaults to auto size is true, is that normal?
    Yes. I never used the original VS.NET (2002) but it has certainly been that way since VS.NET 2003. It makes perfect sense if you think about it. In the case of a Label, you're generally going to want to see all the text and nothing but the text, so it's logical that the control size itself relative to its text. Most other controls would not autosize by default because it wouldn't make sense to do so.
    Quote Originally Posted by sdowney1 View Post
    And can the label transparency be set to allow an image in the Picture box control shine through the label?
    Transparency in Windows Forms is not real. A "transparent" control simply copies the area of its parent that it covers and draws that as its background. If you add a Label to a form then it will draw the form as its background, even if there's a PictureBox or something else between it and that form. If you want a PictureBox to show through a transparent label, you have to make the PictureBox the parent of the Label. That cannot be done in the designer, even by manually editing the designer code. You have to do it in code at run time. Here's what you do:

    1. Add the PictureBox and the Label to the form.
    2. Make sure that the Label is higher in the z-order than the PictureBox, so it appears in front. You can use the Document outline window to change the z-order of any control, or you can right-click a control and select Bring to Front or Send to Back.
    3. Position the Label where you want it relative to the PictureBox. It must be wholly inside the PictureBox or it will be cut off when you change the parent.
    4. Add the following code to your form's Load event handler, changing the names as required:
    Code:
    Dim position = PictureBox1.PointToClient(Label1.PointToScreen(Point.Empty))
    
    With Label1
        .Parent = PictureBox1
        .Location = position
    End With
    That gets the Label's position relative to the form, converts that to coordinates relative to the screen, then converts that to coordinates relative to the PictureBox. It ten moves the Label into the PictureBox, rather than just over it, and changes its Location so it in the same absolute position as before.

    If you need "real" transparency, start using WPF or the like, which was built from the ground up to support such features.
    Last edited by jmcilhinney; Apr 20th, 2024 at 10:33 PM.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  7. #7

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2024
    Posts
    874

    Re: label control has no handles to resize on form at design time, how to give it the

    Quote Originally Posted by jmcilhinney View Post
    Yes. I never used the original VS.NET (2002) but it has certainly been that way since VS.NET 2003. It makes perfect sense if you think about it. In the case of a Label, you're generally going to want to see all the text and nothing but the text, so it's logical that the control size itself relative to its text. Most other controls would not autosize by default because it wouldn't make sense to do so.

    Transparency in Windows Forms is not real. A "transparent" control simply copies the area of its parent that it covers and draws that as its background. If you add a Label to a form then it will draw the form as its background, even if there's a PictureBox or something else between it and that form. If you want a PictureBox to show through a transparent label, you have to make the PictureBox the parent of the Label. That cannot be done in the designer, even by manually editing the designer code. You have to do it in code at run time. Here's what you do:

    1. Add the PictureBox and the Label to the form.
    2. Make sure that the Label is higher in the z-order than the PictureBox, so it appears in front. You can use the Document outline window to change the z-order of any control, or you can right-click a control and select Bring to Front or Send to Back.
    3. Position the Label where you want it relative to the PictureBox. It must be wholly inside the PictureBox or it will be cut off when you change the parent.
    4. Add the following code to your form's Load event handler, changing the names as required:
    Code:
    Dim position = PictureBox1.PointToClient(Label1.PointToScreen(Point.Empty))
    
    With Label1
        .Parent = PictureBox1
        .Location = position
    End With
    That gets the Label's position relative to the form, converts that to coordinates relative to the screen, then converts that to coordinates relative to the PictureBox. It ten moves the Label into the PictureBox, rather than just over it, and changes its Location so it in the same absolute position as before.

    If you need "real" transparency, start using WPF or the like, which was built from the ground up to support such features.
    That works great thanks very much
    Label6 is now 'transparent' with picturebox as it's parent
    Attached Images Attached Images  

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width