So I have a multiple forms and one main form. I show the child forms through a panel. I was wondering if I could make the child forms transparent, that way it would blend in with my background image. Thank you!
Asked
Active
Viewed 85 times
1 Answers
0
Prepare your form and panel
Set your panel
//
// panel1
//
this.panel1.BackColor = System.Drawing.SystemColors.ControlDark;
And your form
//
// Form1
//
this.BackColor = System.Drawing.SystemColors.ControlDark;
this.TransparencyKey = System.Drawing.SystemColors.Control;
Now add child forms
Form form = new Form()
{
TopLevel = false
};
panel1.Controls.Add(form);
form.Show();
Read also
And remember, if you set red color to TransparencyKey
and BackColor
of your form and controls then they will be able to handle mouse events. This is only in case of red color. In other cases Any mouse actions, such as the click of the mouse, that are performed on the transparent areas of the form will be transferred to the windows below the transparent area. For example, if the client region of a form is made transparent, clicking the mouse on that area would send the event notification of the click to any window that is below it. See this and this.

DotNet Developer
- 2,973
- 1
- 15
- 24
-
I still want it to show my background image in Form 1 not making it completely transparent. – lavinge Jun 01 '22 at 04:17
-
Try `this.panel1.BackgroundImage = myImage;`. I mean set your image to panel, not form. – DotNet Developer Jun 01 '22 at 04:19
-
The panel image will have an offset from form1, which doesnt look good – lavinge Jun 01 '22 at 04:25
-
Make adjustments to your panel layout. You can, for example, dock it filling. If there are padding in client area of your form then remove it, so on and son... Make adjustments. – DotNet Developer Jun 01 '22 at 04:29
-
Also take into account the size of your image and `BackgroundImageLayout` property of your panel. – DotNet Developer Jun 01 '22 at 04:34