Click here to Skip to main content
15,892,072 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a MDI Conainer Form wherein I added a menustrip and a FlowLayoutPanel to contain some buttons. I set the BackColor Property of those two control to transparent and implemented a code to change the Container background to my specified image. I am using this code to change the background of the MDI container form

C#
public partial class FormAdminConsole : Form
{
    public FormAdminConsole()
    {
        InitializeComponent();
        DateTimeTimer.Start();

        foreach (Control ctl in this.Controls)
        {
            if (ctl is MdiClient)
            {
                ctl.BackgroundImage = Properties.Resources.background3;
                ctl.BackgroundImageLayout = ImageLayout.Stretch;
                break;
            }
        }
    }



but when I ran the application the background was there but the MenuStrip and the FlowLayoutPanel is not transparent but rather dark-grayish in color.

Is there a way to make these controls to be really transparent?

Thanks in advance. :)
Posted

Are you required to use windows forms? If you can, break free of the the '90s and join the '10s.

Don't worry, my first article on here was forms using MDI (at first), and that was around 2005.

No matter... who owns who? Does the Panel own the MenuStrip? Is the MenuStrip created in another class?

Here's a suggestion without more details (BTW I read your code):
http://stackoverflow.com/questions/14126356/setting-mdi-child-transparency-possible-vb-net[^]

"make MenuStrip and Panels transparent"... Far too broad to get a proper answer. This isn't SO, but please be more specific and you will get a more specific answer.

I hope the link or my broad suggestion gives you some direction.

If you need more assistance, please don't hesitate to ask. Just make your question more specific :)
 
Share this answer
 
Comments
phyxian 23-Oct-15 5:49am    
its not entirely a requirement, though i am almost finished with the application and it would take some time to migrate to wpf; at the moment i am just doing some UI work to make the app look appealing.
Regarding the link, it describes more about child forms, the menu strip and the panel are within the mdi parent, i am asking for a way to make those control transparent, be it code implementation or if not a work around in the control themselves
phyxian 26-Oct-15 21:27pm    
I've reread your answer and to clarify and answer your question about :
"No matter... who owns who? Does the Panel own the MenuStrip? Is the MenuStrip created in another class?"

MenusStrip and FlowLayoutPanel are owned by the MDI container form, whereas there are about 5 buttons (I'm planning to add one or two if needed) that are owned by the FlowLayoutPanel
Not only is using MDI today a mistake (it's outmoded, visually clunky, there are better alternatives), but attempting transparency with controls in Windows Forms is a dead-end. If you put Controls on the special hidden ContainerControl that MDI creates (which is what I assume you are doing), your MDI Child Forms will obscure them if moved over them.

In Windows Forms the only sure way to have usable transparency is to use Forms, and set the 'Opacity property. While you can get away with it, inserting a Form into another Form's ControlsCollection is also a serious error. Another way ... a mistake I think ... is to create Forms with "knocked out" regions (holes) by using GraphicPaths (Regions) and exploiting winding-rule behavior (interaction between region in region).

I suggest you re-think your Application design, post questions here to get ideas, and assistance.
 
Share this answer
 
v2
Comments
phyxian 26-Oct-15 21:20pm    
sorry for this late reply, but when you say

"Not only is using MDI today a mistake (it's outmoded, visually clunky, there are better alternatives)"

what other alternatives are there? I'm curious about those alternatives, but as of today I prefer not to code my application from ground up "again". I just want to know if its possible in MDI to make such control truly transparent; and if its not its ok for me :)

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