Hello,

I want to set the background image of form as per user selection. for that i have take openFileDialog but it only show the wallpapers when i click on open button it not applied to form. it show an error message that "path not found"

this code is on menu strip option

openFileDialog1.ShowDialog();
            DialogResult dialog = MessageBox.Show("Do You Want To Apply This Wallpaper On Your Page","Add WallPaper" ,MessageBoxButtons.YesNo);
            {
                if (dialog == DialogResult.Yes)
                {
                    Form6 fr6 = new Form6();
                    fr6.openFileDialog1.OpenFile();

                }
            }

isnt this code is enough to apply.

Recommended Answers

All 4 Replies

The clue is in your original requirement.

I want to set the background image of form

You need to set the Form.BackgroundImage property.
MSDN BackgroundImage Property

as per site u have given to me. It apply to form which are stored in the imeage list but I want to apply from difrent locations. Example : c drive, d drive where the user stored his images. I tried to make some changes on coding given by the site but it not apply to the form. if you know that which property i have to set to speacify the path yhen plaese tell me..

You can set image from anywhere using the BackgroundImage property.

Here's an example:

this.BackgroundImage = Image.FromFile(@"C:\images\wallpaper.jpg");

You can use BackgroundImage property of form

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.