Click here to Skip to main content
15,914,109 members
Please Sign up or sign in to vote.
4.00/5 (2 votes)
See more:
i want to make transparent panel to show buttons behind it
but i don't know how to send panel's location to it's parent(the form)
when i override InvokePaintBackground()to show buttons in back ground of panel

thanks for help
Posted
Comments
Herman<T>.Instance 21-Jun-12 8:40am    
is there any code we can look into?
Moosavi S.M. 24-Jun-12 10:42am    
my code was borrowed from article "Creating-Transparent-Controls-in-NET-Compact-Frame" in the site!!
i just want to add transpPanel class to my code istead of transplabel in that code!
i'm looking for a way to send panel's location to it's parent(form) in
parent.OnPaintbackground(e) to make the parent draws itself from panel's location into panel's bg to make panel look transparent!!!

your help will be appreciated
Sergey Alexandrovich Kryukov 22-Jun-12 22:48pm    
Why doing it? What do you want to achieve? I don't advise to use transparency in Forms controls, it does not really work.
--SA
Member 13404993 12-Sep-17 2:38am    
On setting transparency only able to see the parent not the button. Any other option to see the button?

As the simple step, if you go to the Backcolor property, and change the Selector to "Web" the first choice is Transparent. I believe that the backcolor of the panel would inherit the color of the component it is on
 
Share this answer
 
Comments
Dave Kreskowiak 22-Sep-13 9:39am    
Yes, but you won't see the controls behind the Panel.
Member 13404993 12-Sep-17 2:40am    
Yah. Any other option to see the button?
Dave Kreskowiak 12-Sep-17 8:19am    
Don't resurrect a five year old question.

Ask your own question by going to the "quick answers" menu and clicking "Ask a question".

Nice CodeProject article is available at A Reflective and Translucent Glass Panel[^]
 
Share this answer
 
Comments
V.Lorz 1-Sep-13 6:01am    
I wouldn't call it 'article'. It is only VB code, with next to nothing of information describing what is done and why.

Just as SA sayd in his comment, transparency doesn't work in WinForm applications. I run the project in Win 8 and played a little bit with it, just to be sure, and the result was 'no transparency'.
BillWoodruff 22-Sep-13 5:31am    
Voted #3. A reasonably appropriate suggestion to the OP; even if the code won't really give you transparency, there's a lot you can learn from studying it.
BillWoodruff 22-Sep-13 5:44am    
@V.Lorz fyi: There is a C# translation version of the cited article's code, in the comments on the article by Chona1171. While Chona's code, like the article's, does not successfully implement transparency (in Win 8), imho it is an extremely useful example to study to see what can be done in WinForms with defining custom backgrounds for a Control. I found Chona's code quite readable.

And, it does work, to a degree, in Win8 (I tested the C# version only), creating rather pleasant looking Panels with a gradient fill, rounded corners, an interior thin black outline, etc.

bill
i have found the solution!

override onPaintBackground() eventhandler of the panel and leave it blank
so every time the panel redraws it fills nothing in it's bg so behind objects
will appear!

protected override void onPaintBackground("args here")
{
//blank
}
 
Share this answer
 
Comments
Dave Kreskowiak 22-Sep-13 9:40am    
Yeah, you might want to test that more extensively. Try dragging another window over the top of that panel to make sure it's going to do what you want.
BillWoodruff 23-Sep-13 3:14am    
If you wanted a Panel to just disappear, so Controls behind it "show up," why don't you just hide it ? If your goal is to show Controls, but not to allow the user to interact with them, why not just disable the Controls ?

Your question never really stated your goal here clearly.

But, as others here have commented, I think it's a waste of time to try and achieve any really useful transparency function with a Win Control (although some, like, Label, have that built-in).

Years ago, I spent some time researching, and experimenting, trying to create a variable transparency Panel, and it "kind-of" worked, but was never satisfactory: the Panel cannot be double-buffered; it will not properly re-draw what's behind it when transparency is changed at run-time, etc.; it will display odd behavior at design-time, "capturing" a kind of screen shot of what it's over when you move it, and so forth. For true transparency, I think you should consider WPF.
Member 13404993 12-Sep-17 2:46am    
I have a control with a context menu. But now I want to see the same control with different context menu from previous. So my plan is to put a transparent panel over the control and add new context on that transparent panel. But on setting bgcolor to transparent it shows the parent. How will I show that control below the panel?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900