My application has a main form which is the parent of ALL MDIChild forms. It has its own cool little background.
I want to have 4 buttons on the Main Form that load a different form in the MDI Container. My form is transparent so all the little designs ive made for my picture box buttons overlap the main form nicely UNTIL Visual Studio paints that stupid background grey when you set the IsMDIContainer property to true. The buttons now have greyspots (as they are transparent and its like it bleeds through the background image and into the greyspot of the MDI Container).
I've googled this for hours and no one has answer. I want the buttons to be transparent to the Main Forms BG Image and NOT the grey MDIContainer BG.
Using VS2019, VB.NET The image above shows Form1 with the background and an overlayed Form 5 with all the controls. I wanted the 2 cloud looking buttons at the bottom (which are supposed to be on the Parent Form 1) to not have that grey box around them but to be transparent to the Form1 background image.
First, you could use this code under your mdi parent load event:
For Each ctl As Control In Me.Controls
If TypeOf ctl Is MdiClient Then
ctl.BackColor = Me.BackColor
End If
Next ctl
but it will work only if you set a plain color (e.g. only red or orange or any other color) as backcolor to this mdi parent form, but doesn't work with images.
you must know that mdi parent forms are designed to show only the child forms, so if you want a background image for your form just use a regular form then add a panel or multiple panels to it instead of your mdi child forms which will do the same job plus enabling controls transparency.
for your information, mdi child forms is a very old technique which is rarely used today.
Related
I have an MDI windows form and many child windows forms in vb.net. What exactly done that the Mdi form have a PictureBox control over it. If I call a child form from mdi form then PictureBox of MDI form overlap the child form mean it hides the child form behind the PictureBox of MDI windows form.
How to send PictureBox behind windows forms?
This is how i approached the situation.
Since i am using a MDI-Parent Form and other Child Forms, I thought to Show() the picture box (pbImage.Show()) when the MDI Parent Control is doing nothing. If we open a new Child form, then we Hide() the pictureBox. Worked for me.
There are some facts about MDI Container Form that you should know:
The client area of the form is filled by MdiClient control which hosts all MDI children. So if you add a Control to the MDI parent, it will be located in front of the MdiClient and so it will be shown in front of MDI child forms.
You can not add any control to MdiClient control. It just allow adding MDI child forms.
To show a picture in MDI parent, you can set BackgroundImage and BackgrroundImageLayout, for example:
Dim mdiClient = Me.Controls.OfType(Of MdiClient)().First()
AddHandler mdiClient.Resize, Sub(s, a) mdiClient.Invalidate()
Me.BackgroundImage = My.Resources.SomeImage
Me.BackgroundImageLayout = ImageLayout.Center
I have a form with an A4 image in the background (a standard questionaire). on that form i have textfields to fill. But if we scroll to the bottom of the form, the textfields scroll, but the background does not. How to fix the background to stick with the texfields ? VB.NET visual studio 2010.
Place a panel on the Form.
Place all your controls inside the panel.
Set the Background of the panel to your image.
Size your panel so that it is large enough to hold all the controls.
Place the panel at 0,0
Set the Form to AutoScroll
I am trying to make a transparent control with child controls that are visible and opaque.
I have added a panel control to the main form via code in the form load event. In this I am adding five buttons as child controls like: panel.controls.add(). To all of these, I have set backcolor=color.transparent.
When I run this program, the button background shows the background of the next button in the panel. If I open a child form, then I can see labels on the child form as the background of the panel.
I want to make container panel control completely transparent, so I can see the main form through it. How can this be achieved?
When the form loads, you can see neighbor buttons behind the actual buttons
"Perform Check" is a label on a child form which I opened right before taking this picture.
: "Check Cases and Combinations" is a button on a child form which I opened right before I took this picture.
How can I make it truly transparent? Why doesn't the background of the panel control refresh with the main form background? The panel sort of "keeps" whatever happens on the main form and shows it as a background.
I found out there some issues with setting controls that are transparent and on top of other controls in the main form. They take the background of the container form, whether or not there is any control in between. I used WPF form instead of the panel and it worked perfectly.
With winforms, you can set Transparency of a form via setting up the TransparencyKey and the Backcolor of the form into the same color in the properties window.
However, the tabpages in the TabControl doesn't have these properties.
How will I make it so that a tabpage will show the desktop's contents?
Also, is there a way for me to show the icons in my desktop on the tabpage? The icons must still function as normal(can be double clicked to open the file, single clicked to rename and can be dragged around inside my tabpage.)
I am using VB.NET 2005. Any direction is greatly appreciated.
Apparantly, the answer is quite simple.
Just set the TransparencyKey of a form to a color that you wish to appear as transparent, then set the backcolor of the tabpage to that color (the color you've set on your form).
One would imagine that clicking anywhere within the MDI Child form (or on any control) will focus that form. But in my application I can only focus a MDI child by clicking on its titlebar, which is an abnormal behavior on the part of the user. My forms are filled with either controls or panels so I don't have the luxury of just "clicking on the form." But clicking anywhere within it should focus it.
I haven't been able to find a solution to this problem although it seems others are having it as well.
I figured it out. If you are setting the child form mdiParent property after you are calling Form.Show then it messes up the focus of all the child forms.
When I set mdiParent property of the form first and then call .Show(), everything works perfectly as expected.