[RESOLVED] Transparent labelbox above Picturebox
Hi guys :wave:
I'm playing with some new UI for one of my projects. I have created a digital display board in Photoshop and added a Picturebox in my VB project and used that image in it.
But what I want to do is, I'll be displaying some text above that image. When I tried placing a LabelBox and setting it's BackColor to Transparent, doesn't work !
The text in the LabelBox will be changing each second. So, what I'm doing is using a Timer control with 1000 as interval and displaying the text.
What will be the solution ? Do I have to draw the text on the picturebox on Paint event ?:confused:
Thanks :wave:
Re: Transparent labelbox above Picturebox
A control with a transparent background will display its parent. If the Label's parent is the form, you'll see the form through the Label. You need to make the PictureBox the Label's parent, which you can't do in the designer. Position the Label where you want it and then use code like this:
vb.net Code:
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
Me.Label1.Location = Me.PictureBox1.PointToClient(Me.PointToScreen(Me.Label1.Location))
Me.Label1.Parent = Me.PictureBox1
End Sub
That assumes that the Label's original parent is the form. If not, call PointToScreen on the Label's original parent control.
Re: Transparent labelbox above Picturebox
Thanks jm :wave:
It was inside a SplitPanel and I used this code:
vb.net Code:
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
Me.Label1.Location = Me.PictureBox1.PointToClient(SplitPanel4.PointToScreen(Me.Label1.Location))
Me.Label1.Parent = Me.PictureBox1
End Sub
:thumb:
Re: [RESOLVED] Transparent labelbox above Picturebox
It occurred to me that you could always just do this:
vb.net Code:
Me.Label1.Location = Me.PictureBox1.PointToClient(Me.Label1.Parent.PointToScreen(Me.Label1.Location))
Re: [RESOLVED] Transparent labelbox above Picturebox
Thanks :wave:
That's also working :thumb:
vb.net Code:
Me.lblElapsed.Location = Me.PictureBox1.PointToClient(Me.lblElapsed.Parent.PointToScreen(Me.lblElapsed.Location))
Me.lblElapsed.Parent = Me.PictureBox1
:wave:
Re: Transparent labelbox above Picturebox
[edit: a whole correspondence took place while I was working out my reply. Never mind:o]
Re: Transparent labelbox above Picturebox
Quote:
Originally Posted by
boops boops
[edit: a whole correspondence took place while I was working out my reply. Never mind:o]
You were slow :p
Thanks for trying out to find a solution. :wave:
Re: [RESOLVED] Transparent labelbox above Picturebox
It occurred to me further that you could also do this:
vb.net Code:
Me.Label1.Location = Me.PictureBox1.PointToClient(Me.Label1.PointToScreen(Point.Empty))
Re: [RESOLVED] Transparent labelbox above Picturebox