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.
Re: label control has no handles to resize on form at design time, how to give it the
Originally Posted by sdowney1
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.
Originally Posted by sdowney1
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.
Re: label control has no handles to resize on form at design time, how to give it the
Originally Posted by jmcilhinney
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