Click here to Skip to main content
15,846,144 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
My problem is somehow related to[^]

What I have tried:

but the main problem is I only have one form in my project and inside this one form only , i had to allocate a space where i can open and close the above fade form and the focus form so i used a panel . I have asked this question in many forums but no one answered . I am using panel to open and close forms but got suggestion to create a user control instead but no one never told me to how to design that user control and how to use that . If any one here has the time here to help me , please do so .

I have a panel in my form and there is form named form1 opened inside a panel . I want to add this fade form over this form1 so that the control of form1 should be partially visible and when this happened , I want to open a focus form of which the link I just shared . Just this I want .
Updated 22-Nov-23 0:29am
Chris Copeland 22-Nov-23 4:50am    
Why does this need to be inside a panel? The top answer on your SO question provides you with exactly the code needed to show a dialog window with a semi-transparent dark overlay. The use of a panel seems unnecessary?
sanchita aggarwal 22-Nov-23 4:58am    
@chris Copeland , but then where would i open and close the forms .
Chris Copeland 22-Nov-23 5:18am    
The code example in the SO answer gives you code for button_Click. This is the code needed to produce and show your popup message + overlay, so you'd just need to put that wherever it is you're showing the message. Probably the best place would be a static method somewhere, such as OverlayMessage.Show("message");?

If this isn't exactly what you're after then you may need to be more explicit in what you want. From the description in this question, the top answer on SO seems to cover exactly what you need.
sanchita aggarwal 22-Nov-23 5:30am    
@Chris Copeland , i had updated my question . Please take a look
Chris Copeland 22-Nov-23 5:39am    
I'm still not sure I understand what it is exactly you're after. Why are you using a panel at all when the SO answer provides code which:

1) Opens a semi-transparent window which covers the entire form in the darkened overlay
2) Opens the modal dialog which can serve as your message container

I think the answer here is to use more than one form, as the answer's code provides.

"and there is form named form1 opened inside a panel."

You shouldn't be opening a form within a panel. When a new form is created and shown it's displayed over the top of your form. What precisely about the SO answer doesn't accomplish what you're asking for? Is there specifically something you need to happen that the example code doesn't achieve?

1 solution

Its a bit hard to visualize what you are trying to achieve, but it sounds like you are trying to create your own version of forms modal operation.

see the following link

Form.Modal Property (System.Windows.Forms) | Microsoft Learn[^]
Share this answer

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