Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Inherited forms
Message
Information générale
Forum:
ASP.NET
Catégorie:
The Mere Mortals .NET Framework
Titre:
Divers
Thread ID:
01151465
Message ID:
01151565
Vues:
31
Hi!

Try this
string Backpath = "a path+filename to a bmp or a gif file";
Change_BackgroundImage(Backpath);

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);

                        break;

                    }

                }

             }

        }
Sarosh

>Darrell,
>
>>I am inheriting the mmMainAppForm. How do I change the backcolor of the form? No mater what I do, it seems to go to a color called AppWorkSpace.
>
>This is one of those Windows Forms "points of interest" <g>. I remember messing with this for quite a while when .NET 1.0 was first out...I thought...certainly, it's me <bg>.
>
>ANYWAY, in order to change the background color of an MDI parent form, you have to set its BackgroundImage property to an image of the desired color...not intuitively obvious! For example, you can create a .bmp or .gif file that is pure white if you want a solid white background. Note that the color will not be changed at design time, but it will render correctly at run time.
>
>Best Regards,
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform