Click here to Skip to main content
15,892,298 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,I created this form for changing wallpaper in my C# program on Visual Studio and it's working except when I change the wallpaper in a form, close the form & open again the wallpaper I see is the previous wallpaper & my chosen wallpaper doesn't stay permanently.
This is how I choose and change my wallpaper:

C#
Object pic = Properties.Resources.ResourceManager.GetObject("wallpaper1");
                    Bitmap mypic = (Bitmap)pic;
                    Frmchangebackcolor fc = new Frmchangebackcolor();
                    fc.BackgroundImage = mypic;
                    fc.ShowDialog();


I use Visual Studio ultimate 2013.

What I have tried:

I'm kinda rookie in this field And I really don't know how to change wallpaper of a form
permanently throw coding.
Posted
Updated 18-Aug-19 19:51pm
v2

1 solution

To change it permanently, you have to store the selection somewhere, and reload that wehn your app starts. To do that, use the "Properties ... settings" branch of your project in the Solutions pane.
Using Application Settings and User Settings | Microsoft Docs[^] will get you started.
 
Share this answer
 
Comments
[no name] 19-Aug-19 2:17am    
Hi,I did as you said but one tiny problem,what is the type for images in settings?
OriginalGriff 19-Aug-19 2:36am    
No, you don't store the image itself in the settings: you store something which lets you know which image to use: a name, an index number, or a path to a JPG file perhaps. Then when you start up, you get that info and decide from that which image to load.

That way, if you change the image in your app and rebuild it, the new image is displayed, not the old one from the settings.
Make sense?
[no name] 19-Aug-19 2:43am    
right

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900