?
Solved

Mdi Parent Form in VB

Posted on 2003-02-19
7
Medium Priority
?
672 Views
Last Modified: 2007-12-19
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
Comment
Question by:Firlefanz
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
7 Comments
 
LVL 4

Expert Comment

by:bgungor
ID: 7982187
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
 

Author Comment

by:Firlefanz
ID: 7985848
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
 
LVL 4

Accepted Solution

by:
bgungor earned 200 total points
ID: 7993799
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
Learn by Doing. Anytime. Anywhere.

Do you like to learn by doing?
Our labs and exercises give you the chance to do just that: Learn by performing actions on real environments.

Hands-on, scenario-based labs give you experience on real environments provided by us so you don't have to worry about breaking anything.

 

Author Comment

by:Firlefanz
ID: 8006787
I don't know, why it's working, but it is working!

Thanks a lot!
0
 
LVL 4

Expert Comment

by:bgungor
ID: 8013296
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
 

Author Comment

by:Firlefanz
ID: 8014592
Thanks a lot bgungor!
This did help me much :)
0
 

Expert Comment

by:MikeMinton
ID: 10312344
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

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A basic question.. “What is the Garbage Collector?” The usual answer given back: “Garbage collector is a background thread run by the CLR for freeing up the memory space used by the objects which are no longer used by the program.” I wondered …
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question