Click here to Skip to main content
13,086,120 members (84,046 online)
Click here to Skip to main content
Add your own
alternative version


13 bookmarked
Posted 2 Sep 2006

MDI Container background

, 2 Sep 2006
Rate this:
Please Sign up or sign in to vote.
Change mdi form background picture at run time

Introduction<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p>


Change mdi form background picture at run time<o:p>

This article demonstrate how to change MDI Container background image at run time <o:p>


Step 1: Create Windows Application Project<o:p>


Please do the following to create a Windows Application project:<o:p>

  • Select File menu -> New -> Project. <o:p>
  • Choose C# from Project Types pane. <o:p>
  • In the Templates pane, choose Windows Application for Visual C# projects. <o:p>

Step 2: <o:p>

            Add Controls<o:p>

1.       Menustrip Control<o:p>

2.       OpenFileDialog Control<o:p>


Change              IsMdiContainer Property = True<o:p>


Step 3: Coding Sections<o:p>

  1. Open Image file <o:p>

private void openToolStripMenuItem_Click(object sender, EventArgs e)<o:p>


    string Backpath = null;<o:p>



          openFileDialog1.Filter = "Jpg|*.jpg";<o:p>


          Backpath = openFileDialog1.FileName;<o:p>

          // calling Image background method<o:p>



  catch (Exception ex)<o:p>





  1. Change_BackgroundImage(Backpath) Method<o:p>

       private void Change_BackgroundImage(string _path )<o:p>


            string imagepath = _path;<o:p>

            System.IO.FileStream fs;<o:p>

            // MDI Form image background layout change here<o:p>

            //(Remember control imagebakground layout take default form background layount )<o:p>

            this.BackgroundImageLayout = ImageLayout.Stretch;<o:p>

            // Checking File exists if yes go ---><o:p>

            if (System.IO.File.Exists(imagepath))<o:p>


                // Read Image file<o:p>

                fs = System.IO.File.OpenRead(imagepath);<o:p>

                fs.Position = 0;<o:p>

                // Change MDI From back ground picture<o:p>

                foreach (Control ctl in this.Controls)<o:p>


                    if (ctl is MdiClient)<o:p>


                        //ctl.BackColor = Color.AntiqueWhite;<o:p>

                        ctl.BackgroundImage = System.Drawing.Image.FromStream(fs);<o:p>







I am looking forward to receive any comments/suggestion you have for me.<o:p>

Thank you for reading; I sincerely hope this article will help you a bit or two to know reporting services better through my applied approach<o:p>







This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Software Developer (Senior)
India India
No Biography provided

You may also be interested in...

Comments and Discussions

GeneralProblem to use this for RightToLeft Layout MDI Form Pin
Farhad Qeshlaqi3-Mar-11 19:28
memberFarhad Qeshlaqi3-Mar-11 19:28 
GeneralA Guide To Writing Articles For Code Project Pin
mwdiablo3-Sep-06 15:33
membermwdiablo3-Sep-06 15:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.170813.1 | Last Updated 2 Sep 2006
Article Copyright 2006 by anishmm
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid