Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 683
  • Last Modified:

Mdi Parent Form in VB

Hello,

I have a form and change the background color to blue. Then I set "isMdiContainer" to true. Now my form's background color is dark grey :(

Why is that?
How can I set the background color of my form, if it is a MdiContainer?

I need a solution in VB.net, please help

Thanks in advance

PS: An Image on the form doesn't help me, I've tried that. Then you cannot see the MdiChilds, because they are behind taht image.
0
Firlefanz
Asked:
Firlefanz
  • 3
  • 3
1 Solution
 
bgungorCommented:
Modified Extract from http://www.syncfusion.com/FAQ/WinForms/FAQ_c4c.asp#q799q

The default behavior is to make the client container use the Control color from the Control panel. You can change this behavior by making the MDI Client container use the any BackColor and Image. To do this, after the call to InitializeComponents(), add the code below. You can also download a working MDI Client project that has this code in it. (see link above)
 
//set back color
 
foreach(Control c in this.Controls)
{
     if(c is MdiClient)
     {
          c.BackColor = this.BackColor; // or System.Drawing.Color.Beige;
          c.BackgroundImage = this.BackgroundImage; // or any Image you choose.
     }
}
 

Hope this helps,

Bg
0
 
FirlefanzAuthor Commented:
Sorry, I somehow posted this topic under .NET.
This topic belong under Visual Basic of .NET.
Thanks for your help, but I do need this in Visual basic.
Can I put this topic under .NET/Visual Basic?

Thanks so far
Firlefanz
0
 
bgungorCommented:
There is no VB.NET subtopic yet.  I have made a translation for you, however.

        Dim c As Control
        For Each c In Me.Controls
            If TypeOf c Is MdiClient Then
                c.BackColor = Me.BackColor ' or System.Drawing.Color.Beige;
                c.BackgroundImage = Me.BackgroundImage ' or any Image you choose.
            End If
        Next


Bg
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
FirlefanzAuthor Commented:
I don't know, why it's working, but it is working!

Thanks a lot!
0
 
bgungorCommented:
The reason this works is because MDI windows automatically add a control of type MdiClient to themselves which serves as the client area of the window.  It doesn't expose this child as a property of the form, because not all forms are MDI.

What you are doing is literally iterating through all of the controls on the MDI form, and where it is an MdiClient type, changing the background color.  

That's all there is to it!

Bg
0
 
FirlefanzAuthor Commented:
Thanks a lot bgungor!
This did help me much :)
0
 
MikeMintonCommented:
Hi

I was also having the same problem, but why in VB6 can you change the Dark Grey to a different color, and not in VB.Net.  In my application I would like to change the Dark Grey to a whiye, which is our corporate color, but i cannot do this.

Is this the difference between VB6 and VB.Net, if so, it seems that there are lot of issues like this.

Hope you can help
Mike Minton.
0

Featured Post

Become an Android App Developer

Ready to kick start your career in 2018? Learn how to build an Android app in January’s Course of the Month and open the door to new opportunities.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now