Results 1 to 3 of 3

Thread: [2005] Making transparent Labels

  1. #1

    Thread Starter
    Hyperactive Member Pac_741's Avatar
    Join Date
    Jun 2007
    Location
    Mexico
    Posts
    298

    [2005] Making transparent Labels

    Hi, I'm working on a project that needs to have transparent labels , since they are going to be on top of a PictureBox, I can make them transparent using this code :

    Vb.net Code:
    1. 'So this changes the parent of the label, and the background becomes transparent
    2. Label1.BackColor=Transparent
    3. Label1.Parent=Image1

    The labels are going to be dragged trough out the form, Being Image1 the control that will host the Labels, when they are being dragged it looks glitchy.

    Here's something else i did, to make things go smoother:



    Since i'm a WPF Developer i incorporated some WPF components to the app, since WPF controls don't have this kind of problems.

    So, using a WPF canvas, the labels look really smooth, no glitch at all, but the problem using that is the background becomes white, the form's color.

    Now what i want to know is how can i make truly transparent labels ?

    Thanks
    C# and WPF developer
    My Website:
    http://singlebits.com/

  2. #2
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,424

    Re: [2005] Making transparent Labels

    truly transparent labels aren't possible in vb.net - they were in vb6 though

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

    Re: [2005] Making transparent Labels

    To qualify .pauls.'s statement, the WinForms Label control doesn't support true transparency. A Label with its BackColor set to Transparent will simply draw its background using the area of its parent that it's covering. If the Label spans two controls then it can't draw the background of both. You'd have to create your own custom control, either by inheriting the Label or from scratch, and then handle drawing its background yourself based on everything behind it. Not a trivial matter.
    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

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