Results 1 to 16 of 16

Thread: transparent labels really gone?**resolved**

  1. #1

    Thread Starter
    Addicted Member Halon's Avatar
    Join Date
    Oct 2002
    Location
    under desk choking on rage
    Posts
    228

    transparent labels really gone?**resolved**

    I am upgrading an app from vb6 to .net and found that all labels were converted to images because there is no transparent property anymore. Is there no way around this?
    Last edited by Halon; Dec 3rd, 2002 at 11:50 AM.
    Soylent Green tastes like chicken

  2. #2
    Member
    Join Date
    Sep 2002
    Location
    California
    Posts
    52
    Set the BackColor property to Transparent.

  3. #3
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428
    Originally posted by wyrd
    Set the BackColor property to Transparent.
    no that doesnt work. That will just change the backcolor of the label to match the backcolor of the form.....

    I have a picturebox in my form which is supposed to be the background of the form, and I have some labels on my form. Since they;re not transparent, it looks kinda ugly
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  4. #4

    Thread Starter
    Addicted Member Halon's Avatar
    Join Date
    Oct 2002
    Location
    under desk choking on rage
    Posts
    228
    Actually it worked like a charm ... i have a custom skin that the imagebox sits on and you can see right through it just like the old labels did. Thanks for the tip wyrd

    Mr. Polite ... Prob doesn't work for labels...i stuck with the imagebox's
    Soylent Green tastes like chicken

  5. #5
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428
    Originally posted by Halon
    Actually it worked like a charm ... i have a custom skin that the imagebox sits on and you can see right through it just like the old labels did. Thanks for the tip wyrd

    Mr. Polite ... Prob doesn't work for labels...i stuck with the imagebox's
    eeh so what did you do? you made a transparent label?
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  6. #6
    Member
    Join Date
    Sep 2002
    Location
    California
    Posts
    52
    MrPolite:

    I just added a background image to my form, then added a label with BackColor set to Transparent. It worked fine.

    Note: The Transparent option is under the Web tab.

  7. #7
    Junior Member RvA's Avatar
    Join Date
    Oct 2002
    Location
    USA
    Posts
    19
    Hello MrPolite,

    Ok I found a this at the MSDN site.

    Giving Your Control a Transparent Background

    In the Public Sub New section of your form add the following line after the "InitializeComponent()"
    VB Code:
    1. SetStyle(ControlStyles.SupportsTransparentBackColor, True)

    Like below:
    VB Code:
    1. #Region " Windows Form Designer generated code "
    2.  
    3.     Public Sub New()
    4.         MyBase.New()
    5.  
    6.         'This call is required by the Windows Form Designer.
    7.         InitializeComponent()
    8.  
    9.         'Add any initialization after the InitializeComponent() call
    10.         SetStyle(ControlStyles.SupportsTransparentBackColor, True)
    11.  
    12.     End Sub
    Then in the constructor section of the label add the following line.
    VB Code:
    1. Me.Label1.BackColor = System.Drawing.Color.Transparent
    Which will look like this:
    VB Code:
    1. '
    2.     'Label1
    3.     '
    4.     Me.Label1.BackColor = System.Drawing.Color.Transparent
    5.     Me.Label1.Location = New System.Drawing.Point(28, 40)
    6.     Me.Label1.Name = "Label1"
    7.     Me.Label1.Size = New System.Drawing.Size(220, 68)
    8.     Me.Label1.TabIndex = 0
    9.     Me.Label1.Text = "Label1"
    Once you have all that done the label will be transparent from then on.

    Hope this helps a little...
    Best,

    Roger

    VB6.0 SR5 & VB.Net Pro
    -----------------------------------------------
    Do or do not, there is no try!

  8. #8

    Thread Starter
    Addicted Member Halon's Avatar
    Join Date
    Oct 2002
    Location
    under desk choking on rage
    Posts
    228
    hmmm .. seemed a lot easier to just set the backcolor to transparent like wyrd was mentioning. Is there a reason to do it the other way?
    Soylent Green tastes like chicken

  9. #9
    Member
    Join Date
    Sep 2002
    Location
    California
    Posts
    52
    He was just telling you how to make images transparent.

  10. #10
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428
    I did that, but it's not working:

    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  11. #11
    Addicted Member
    Join Date
    Jul 1999
    Posts
    207
    Try this:

    Set the labels background property to this: 0,255,0,0

    Jeremy

  12. #12
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    why not just put the label above the button? or can't it be done?
    \m/\m/

  13. #13
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    Are you setting the image in the form's BackgroundImage property? It doesn't work otherwise.

    I tried stretching an image in a pciturebox over the form but all the 'transparent' controls then had the background that matched the form still. So they really aren't transparent, they just draw the form in the background.

  14. #14
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428
    Originally posted by Edneeis
    Are you setting the image in the form's BackgroundImage property? It doesn't work otherwise.

    I tried stretching an image in a pciturebox over the form but all the 'transparent' controls then had the background that matched the form still. So they really aren't transparent, they just draw the form in the background.
    well I have a picturebox under the label
    so what does that setStyle thingie do? redraw's the form's background in the transparent control? that's not gunno help me

    I could make my own label control that would redraw the background in a certain picturebox, but that would probably be inefficient, like everything else that I try to do
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  15. #15
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    Can you set the picture as the form backgroundimage instead of in the picturebox? Is it just me or does it seem like MS took a step backwards on this one?

  16. #16
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428
    Originally posted by Edneeis
    Can you set the picture as the form backgroundimage instead of in the picturebox? Is it just me or does it seem like MS took a step backwards on this one?
    I think they did take a step backwards

    well I'm making a program, and the whole program is like a WIZARD, kinda like the way you burn CD's in nero. So I thought the best way to do something like this is to put each step of my program in a tabpage. So I have a tabcontrol, with some tabpages which contain the different steps of the program.... Each one has it's own background. I dont know if there is a better way besides using a tabcontrol for this
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

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