Click here to Skip to main content
12,508,112 members (47,841 online)
Click here to Skip to main content
Add your own
alternative version


13 bookmarked

MDI Container background

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



Change mdi form background picture at run time

This article demonstrate how to change MDI Container background image at run time


Step 1: Create Windows Application Project


Please do the following to create a Windows Application project:

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

Step 2:

            Add Controls

1.       Menustrip Control

2.       OpenFileDialog Control


Change              IsMdiContainer Property = True


Step 3: Coding Sections

  1. Open Image file

private void openToolStripMenuItem_Click(object sender, EventArgs e)


    string Backpath = null;



          openFileDialog1.Filter = "Jpg|*.jpg";


          Backpath = openFileDialog1.FileName;

          // calling Image background method



  catch (Exception ex)





  1. Change_BackgroundImage(Backpath) Method

       private void Change_BackgroundImage(string _path )


            string imagepath = _path;

            System.IO.FileStream fs;

            // MDI Form image background layout change here

            //(Remember control imagebakground layout take default form background layount )

            this.BackgroundImageLayout = ImageLayout.Stretch;

            // Checking File exists if yes go --->

            if (System.IO.File.Exists(imagepath))


                // Read Image file

                fs = System.IO.File.OpenRead(imagepath);

                fs.Position = 0;

                // Change MDI From back ground picture

                foreach (Control ctl in this.Controls)


                    if (ctl is MdiClient)


                        //ctl.BackColor = Color.AntiqueWhite;

                        ctl.BackgroundImage = System.Drawing.Image.FromStream(fs);







I am looking forward to receive any comments/suggestion you have for me.

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







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.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.160927.1 | Last Updated 2 Sep 2006
Article Copyright 2006 by anishmm
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid