Results 1 to 4 of 4

Thread: How To Change The Background On MDI Parent

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 2006
    Posts
    121

    How To Change The Background On MDI Parent

    How do I change the background on a MDI parent window?

    The easy answer would be to set the background property of the form to whatever color but that doesnt work.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: How To Change The Background On MDI Parent

    That's because you cannot see the background of the form because it is obscured by an MdiClient control. That's the grey area that you can see and what actually hosts the child forms. You are not supposed to access it directly so there is no member variable created. To get a reference to it you simply need to iterate over the Controls collection of the form until you find one that is an MdiClient.
    Code:
        public partial class Form1 : Form
        {
            private MdiClient childHost;
    
            public Form1()
            {
                InitializeComponent();
            }
    
            private void Form1_Load(object sender, EventArgs e)
            {
                foreach (Control ctl in this.Controls)
                {
                    if (ctl.GetType() == typeof(MdiClient))
                    {
                        // This is the control that hosts the child forms.
                        this.childHost = (MdiClient)ctl;
                        break;
                    }
                }
            }
        }
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3
    Frenzied Member dynamic_sysop's Avatar
    Join Date
    Jun 2003
    Location
    Ashby, Leicestershire.
    Posts
    1,142

    Re: How To Change The Background On MDI Parent

    if you go way back to page 4 in the vb.net codebank, you will find an example of creating custom mdi background colours.
    it's in vb.net, but very easy to translate over to C#.
    the link is ... Custom Background Colours in MdiForm / MdiChild.
    ~
    if a post is resolved, please mark it as [Resolved]
    protected string get_Signature(){return Censored;}
    [vbcode][php] please use code tags when posting any code [/php][/vbcode]

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Jan 2006
    Posts
    121

    Re: How To Change The Background On MDI Parent

    Perfect. Thanks alot guys

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width