Trying to make a transparent panel

P

Phil

I have some controls that I want to group together onto a panel, so that I
can dock them on a form. I want the contained controls to be at the top of
the Z-order so that they can always be seen, but I want the panel itself to
be at the bottom of the Z-order so that other controls on the form will not
be hidden by it (except when they're behind the contained controls). I
thought setting the BackColor of the Panel to Transparent might give the
desired effect, but it doesn't seem to work.
Is there another container similar to a Panel, that doesn't have a filled-in
background?
Any other suggestions?

TIA
Phil.
 
L

Linda Liu [MSFT]

Hi Phil,

Based on my understanding, you have a Panel on a form and the Panel has
some controls in it. What you want is to make the Panel transparent so that
the controls that are under the Panel, if any, won't be covered by the
Panel. If I'm off base, please feel free to let me know.

In fact, the Panel supports a transparent effect inherently. If the parent
form has a background image, the Panel with the BackColor property set to
Transparent will display the background image of the parent form and won't
cover the image. But if there is another control between the Panel and its
parent form, the Panel will not show the control in the middle. An MSDN
document has pointed this out explicitly:

http://msdn2.microsoft.com/en-us/library/system.windows.forms.controlstyles(
VS.71).aspx

In my opinion, it wouldn't be a case that some controls would appear under
a Panel on a form. When we design the form, we can definitely avoid this.

Hope this helps.
If you have any concern, please feel free to let me know.

Sincerely,
Linda Liu
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 
P

Phil

Based on my understanding, you have a Panel on a form and the Panel has
some controls in it. What you want is to make the Panel transparent so
that
the controls that are under the Panel, if any, won't be covered by the
Panel. If I'm off base, please feel free to let me know.

That's what I was trying to acheive yes.
In fact, the Panel supports a transparent effect inherently. If the parent
form has a background image, the Panel with the BackColor property set to
Transparent will display the background image of the parent form and won't
cover the image. But if there is another control between the Panel and its
parent form, the Panel will not show the control in the middle. An MSDN
document has pointed this out explicitly:

http://msdn2.microsoft.com/en-us/library/system.windows.forms.controlstyles(
VS.71).aspx

Yes, that explains the problem, exactly:
"This is not true transparency".
"If there is another control between the control and its parent, the
current control will not show the control in the middle."
In my opinion, it wouldn't be a case that some controls would appear under
a Panel on a form. When we design the form, we can definitely avoid this.

I daresay it's possible to design the form to avoid this. However, if the
panel is docked, and the form is resizeable, any fixed controls on the form
can become covered by the panel.

My problem is I have a group of controls that I always want to appear at the
bottom right of the form. I thought a nice simple way to acheive this would
be to put a panel on the form with Dock=bottom and another panel within that
panel with Dock=right. This works well, but it means there is a big unusable
space to the left of my controls. I thought if I could make the first panel
transparent, other controls on the form could be seen through it, but this
obviously doesn't work.

I suppose a better approach will be to just have one panel which is not
docked, and then position it myself in the form's Resize event.
 
R

rowe_newsgroups

That's what I was trying to acheive yes.





Yes, that explains the problem, exactly:
"This is not true transparency".
"If there is another control between the control and its parent, the
current control will not show the control in the middle."




I daresay it's possible to design the form to avoid this. However, if the
panel is docked, and the form is resizeable, any fixed controls on the form
can become covered by the panel.

My problem is I have a group of controls that I always want to appear at the
bottom right of the form. I thought a nice simple way to acheive this would
be to put a panel on the form with Dock=bottom and another panel within that
panel with Dock=right. This works well, but it means there is a big unusable
space to the left of my controls. I thought if I could make the first panel
transparent, other controls on the form could be seen through it, but this
obviously doesn't work.

I suppose a better approach will be to just have one panel which is not
docked, and then position it myself in the form's Resize event.

If you don't need to resize the panel couldn't you just anchor it to
the bottom-right and achieve what you need?

Thanks,

Seth Rowe
 
P

Phil

If you don't need to resize the panel couldn't you just anchor it to
the bottom-right and achieve what you need?

I'd forgotten about anchors. I haven't used those yet, but I do remember
reading a bit about them.
Thanks for reminding me. I'll go and have a play with that.

Cheers,
Phil.
 
P

Phil

I'd forgotten about anchors. I haven't used those yet, but I do remember
reading a bit about them.
Thanks for reminding me. I'll go and have a play with that.

That works perfectly. Exactly the effect I was after.

Thanks,
Phil.
 
P

Phil

Phil said:
That works perfectly. Exactly the effect I was after.
Well not 'exactly' but near enough. I still can't see the controls when they
move behind my panel, but at least now I can make my panel much smaller. If
I put my controls that are on the panel close together, you don't really
notice.
 
R

rowe_newsgroups

Well not 'exactly' but near enough. I still can't see the controls when they
move behind my panel, but at least now I can make my panel much smaller. If
I put my controls that are on the panel close together, you don't really
notice.

I assume the only time your panel hides other controls is when you
shrink the form? If so just specify a minimum size for the form that
when prevent the overlap from occurring.

Thanks,

Seth Rowe
 
P

Phil

Phil said:
Well not 'exactly' but near enough. I still can't see the controls when
they move behind my panel, but at least now I can make my panel much
smaller. If I put my controls that are on the panel close together, you
don't really notice.
but of course, now I can remove the panel altogether, and set the anchor for
each of the controls individually.
 
P

Phil

I assume the only time your panel hides other controls is when you
shrink the form? If so just specify a minimum size for the form that
when prevent the overlap from occurring.

Yes, I'll probably end up doing something like that, but I may need to
implement some scrolling, so that I can put lots of stuff on one form
without having to worry about some people having smaller screens..
At the moment, I'm just playing around with a few options.

Thanks.
Phil
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top