Results 1 to 9 of 9

Thread: [RESOLVED] Transparent labelbox above Picturebox

  1. #1

    Thread Starter
    Freelancer akhileshbc's Avatar
    Join Date
    Jun 2008
    Location
    Trivandrum, Kerala, India
    Posts
    7,652

    Resolved [RESOLVED] Transparent labelbox above Picturebox

    Hi guys

    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 ?

    Thanks

    If my post was helpful to you, then express your gratitude using Rate this Post.
    And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
    My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet

    Social Group: VBForums - Developers from India


    Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    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:
    1. Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
    2.     Me.Label1.Location = Me.PictureBox1.PointToClient(Me.PointToScreen(Me.Label1.Location))
    3.     Me.Label1.Parent = Me.PictureBox1
    4. End Sub
    That assumes that the Label's original parent is the form. If not, call PointToScreen on the Label's original parent control.
    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

  3. #3

    Thread Starter
    Freelancer akhileshbc's Avatar
    Join Date
    Jun 2008
    Location
    Trivandrum, Kerala, India
    Posts
    7,652

    Re: Transparent labelbox above Picturebox

    Thanks jm

    It was inside a SplitPanel and I used this code:
    vb.net Code:
    1. Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
    2.     Me.Label1.Location = Me.PictureBox1.PointToClient(SplitPanel4.PointToScreen(Me.Label1.Location))
    3.     Me.Label1.Parent = Me.PictureBox1
    4. End Sub


    If my post was helpful to you, then express your gratitude using Rate this Post.
    And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
    My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet

    Social Group: VBForums - Developers from India


    Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [RESOLVED] Transparent labelbox above Picturebox

    It occurred to me that you could always just do this:
    vb.net Code:
    1. Me.Label1.Location = Me.PictureBox1.PointToClient(Me.Label1.Parent.PointToScreen(Me.Label1.Location))
    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

  5. #5

    Thread Starter
    Freelancer akhileshbc's Avatar
    Join Date
    Jun 2008
    Location
    Trivandrum, Kerala, India
    Posts
    7,652

    Re: [RESOLVED] Transparent labelbox above Picturebox

    Thanks

    That's also working
    vb.net Code:
    1. Me.lblElapsed.Location = Me.PictureBox1.PointToClient(Me.lblElapsed.Parent.PointToScreen(Me.lblElapsed.Location))
    2.         Me.lblElapsed.Parent = Me.PictureBox1

    If my post was helpful to you, then express your gratitude using Rate this Post.
    And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
    My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet

    Social Group: VBForums - Developers from India


    Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...

  6. #6
    PowerPoster boops boops's Avatar
    Join Date
    Nov 2008
    Location
    Holland/France
    Posts
    3,201

    Re: Transparent labelbox above Picturebox

    [edit: a whole correspondence took place while I was working out my reply. Never mind]

  7. #7

    Thread Starter
    Freelancer akhileshbc's Avatar
    Join Date
    Jun 2008
    Location
    Trivandrum, Kerala, India
    Posts
    7,652

    Re: Transparent labelbox above Picturebox

    Quote Originally Posted by boops boops View Post
    [edit: a whole correspondence took place while I was working out my reply. Never mind]
    You were slow

    Thanks for trying out to find a solution.

    If my post was helpful to you, then express your gratitude using Rate this Post.
    And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
    My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet

    Social Group: VBForums - Developers from India


    Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...

  8. #8
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [RESOLVED] Transparent labelbox above Picturebox

    It occurred to me further that you could also do this:
    vb.net Code:
    1. Me.Label1.Location = Me.PictureBox1.PointToClient(Me.Label1.PointToScreen(Point.Empty))
    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

  9. #9

    Thread Starter
    Freelancer akhileshbc's Avatar
    Join Date
    Jun 2008
    Location
    Trivandrum, Kerala, India
    Posts
    7,652

    Re: [RESOLVED] Transparent labelbox above Picturebox

    Thanks

    If my post was helpful to you, then express your gratitude using Rate this Post.
    And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
    My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet

    Social Group: VBForums - Developers from India


    Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...

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