Button transparency problem: Doesn't respect Z-Order

I'll try to make it short.  To show you my problem i've created a picture to illustrate my problem: http://www.ideomation.com/bug.jpg

The first 2 buttons (Librarie) is what i get when my form background contain the image of the button, and that i set my button background to be transparent & flat, and set the FlatAppearance MouseOverBackColor property to black.  The first image is when the mouse is out of the button, and the 2nd is when it's over it.

Under the red line, you can see a button "Renommer" that i misplaced to show my problem.  This happen when i place a transparent button over a picturebox.  The transparent button doesn't show the picturebox under the button, but it show the form background image!

Does transparency should respect the Z-Order of items placed on my form?
If so... why am i getting this error and how can i solve this problem?

I thought about writting a piece of code to just hide the picturebox when the mouse is over the button, and it work, but the problem is that it doesn't look like my black "librairie" button because the shadow dissappear with the picturebox!

Thanks for your help
LVL 10
Christian de BellefeuilleProgrammerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Joel CoehoornDirector of Information TechnologyCommented:
I seem to remember reading somewhere that the .Net controls aren't really transparent, but just fake by taking a snapshot of what's behind them when they load.  That could be your problem.  Then again, I could be completely off my rocker.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
what about the trans of the pic box ?

waiting for your reply
Christian de BellefeuilleProgrammerAuthor Commented:
Smart Man...

The idea is to have a Transparent Button over a Non-Transparent PictureBox...
why would i set it as tranparent?
sorry but i had to ask this question. it looked like you want the button to show the form and the picture box is getting your way.

a work around is to loading the pic at the form. or to use image box.

does the white box that shows inside your button have the same size of teh pic box ?

waiting for your reply
Christian de BellefeuilleProgrammerAuthor Commented:
An image box?  What kind of component is that?  I don't see any Image box anywhere in VS2005.  There's a PictureBox, and an ImageList.  The ImageList is not used to show pictures since it have no space on the form.

To answer your question, the white box doesn't have the same size than the picture.  It's lightly smaller than the image itself because i want to be able to see the shade of the button istelf.

The only workarround i've found is to place every button on the background image of the form, and place some stuff over it and use their visibility to show or hide them.    Example, if i have few buttons over a grid, i must take a snapshot of that grid and create a JPG with it.  Then i add buttons on my background image of the form, then i add a picture box with that blank grid over them to hide the buttons.  

But honnestly, my workarround is just plain stupid...  it would only mean that Microsoft failed to design their stuff.  If you have 3 objects 1 over each other and that the top one have a transparent background, it shouldn't show any color & background and show the item just below it, not the Nth object behind, or even worse the form background!

So my guess is that jcoehoorn was right... it's really a bug of MS and there's no patch for that.

Thanks for your time
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.