Results 1 to 8 of 8

Thread: [RESOLVED] VB.NET Form and Picturebox Transparency HELP!

  1. #1

    Thread Starter
    Member
    Join Date
    Oct 2009
    Posts
    55

    Resolved [RESOLVED] VB.NET Form and Picturebox Transparency HELP!

    Hello everyone! Thank you for your time and interest in reading my post.

    I have a problem. I want to try an simulate a fake lighting system in Visual Basic 2010 by using 2 images. One is Form1's background, and the other is Picturebox2's image. Picturebox2's image is a black background with a transparent circle in the middle. The only problem is, when transparent, it shows the background of the form, and looks right through the background image. How could I get around this so that the transparent part of the image is Form1's background image, and not the backcolor?

    Sorry if that's confusing; I can elaborate more if needed.

    Thanks!

  2. #2
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    8,600

    Re: VB.NET Form and Picturebox Transparency HELP!

    I dont quite understand, could you make it a little clearer what it is you're trying to do and what is actually happening ?

  3. #3

    Thread Starter
    Member
    Join Date
    Oct 2009
    Posts
    55

    Re: VB.NET Form and Picturebox Transparency HELP!

    Quote Originally Posted by Niya View Post
    I dont quite understand, could you make it a little clearer what it is you're trying to do and what is actually happening ?

    I figured someone would say that. I'm terrible at explaining things! :P

    I have Form1 with a background image of 'bg.png'

    I have Picturebox1 with a an image of a square, but part of it's transparent. It doesn't show the Form1's background image, just the backcolor of the form, as if there were no image.

    * SIMPLER TERMS*
    Picturebox = Transparent
    I want picturebox to show form1's background image
    but it doesn't.


    THANKS FOR YOUR TIME, HOPE YOU CAN HELP!

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

    Re: VB.NET Form and Picturebox Transparency HELP!

    Hi coldfire, I thought your initial explanation was perfectly clear. But the cause of the problem isn't. Did you set the BackColor of the picture box to Transparent? Otherwise you will just see through the transparent areas of the image to the picture box's background color (not the background of the form).

    BB

  5. #5

    Thread Starter
    Member
    Join Date
    Oct 2009
    Posts
    55

    Re: VB.NET Form and Picturebox Transparency HELP!

    Quote Originally Posted by boops boops View Post
    Hi coldfire, I thought your initial explanation was perfectly clear. But the cause of the problem isn't. Did you set the BackColor of the picture box to Transparent? Otherwise you will just see through the transparent areas of the image to the picture box's background color (not the background of the form).

    BB
    Wow. I feel like a total idiot; it was that obvious. Thank you so much!

    [RESOLVED]

  6. #6
    Fanatic Member Flashbond's Avatar
    Join Date
    Jan 2013
    Location
    Istanbul
    Posts
    646

    Re: [RESOLVED] VB.NET Form and Picturebox Transparency HELP!

    I have an additional question about this. The transparency only shows the form's background. I have another picturebox1 under picturebox2 but it still shows form's background. Let me give you a snapshot:

    Name:  Capture.PNG
Views: 15596
Size:  391.5 KB
    Is there any trick to solve this problem?

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

    Re: [RESOLVED] VB.NET Form and Picturebox Transparency HELP!

    The transparent parts of a WinForms control show the control's Parent, but not sibling controls. You can't change that, it's the way Forms rendering is designed. That means you could set one PictureBox to be the Parent of another, but then you won't see the form.

    The best way round this is to paint all the cards etc. in the Paint event of the Form using Graphics.DrawImage statements, instead of using PictureBoxes. It may look a little difficult at first, but once you get used to it you can play with transparency as much as you like.

    BB

  8. #8
    Fanatic Member Flashbond's Avatar
    Join Date
    Jan 2013
    Location
    Istanbul
    Posts
    646

    Re: [RESOLVED] VB.NET Form and Picturebox Transparency HELP!

    Got it boops boops. Thanks for detailed information

Tags for this Thread

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