What am I doing wrong?

VB.NET 2005 IDE

I have written an application that is loading image and label controls on the fly.

When I place 1 image containing transparency over another image, the transparency is being ignored.  

Similarly placing a label control over one of these images results in the same problem, despite have the control background set to 'Transparent'.

Doing the same things using the IDE results in the same thing, and I am guessing I am missing a trick here

Can anyone advise me of what I am doing wrong



Answer this question

What am I doing wrong?

  • svuddhi

    Not sure if it is viable for you, but my solution was to override OnPaint and use the Graphics object to just draw strings on the UI without using a Label control. That worked great.

    I assume you could do something similar with drawing Images, just don't use a PictureBox control. Draw it yourself.

    If someone else knows a way around this, please share as I'd be interested in hearing it too.

    Regards,
    Aaron


  • J. Lewis

    I've researched a similar situation. And all signs pointed to Transparency of controls is a load of crock and does not really work.

    For example, on a form I wrote code to paint a gradient over the background.
    Then I added a label and set its back color to Transparent. However, no dice. It still shows up with an ugly square gray background on my form, not acting transparent at all.

    I don't think you are doing anything wrong, I think it just doesn't work.

    Aaron

  • Alfredo_Affonso

    Actually I ran into the same issues with Gradient on a form. I found the following code gets the child controls with transparency to work properly. It might work for your panel as well:

    Private Sub AboutBox1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint

    Dim pbrush As New System.Drawing.Drawing2D.LinearGradientBrush(ClientRectangle, Color.FromKnownColor(KnownColor.ActiveCaption), Color.White, Drawing2D.LinearGradientMode.Vertical)

    e.Graphics.FillRectangle(pbrush, ClientRectangle)

    End Sub


  • What am I doing wrong?