Ok, I figured out how to change my background image that i wanted from a button, but now i need to know how to save the background I chose so the next time i run the program the same background i chose will be there.
Ok, I figured out how to change my background image that i wanted from a button, but now i need to know how to save the background I chose so the next time i run the program the same background i chose will be there.
you are talking about application settings.
you need to create a key for the background image setting and the value for it, then read that value next time your app loads and apply the background to your application.
Take a look at this:
http://msdn2.microsoft.com/en-us/library/k4s6c3a0.aspx
http://msdn2.microsoft.com/en-us/library/a65txexh(VS.80).aspx
http://msdn2.microsoft.com/en-us/library/bc6ws923(VS.80).aspx
http://msdn2.microsoft.com/en-us/library/ms171565(VS.80).aspx
http://msdn2.microsoft.com/en-us/library/wabtadw6(VS.80).aspx
I hope these links help - gives you everything you want :-)
there is no need to use the ini files at all. These are outdated and xml is really a replacement for it. in addition, why re-invent the wheel if .NET provides such functionality and at an ease :-)
The application settings is the way to do it - correctly.
Thanks everyone...but it didnt seem to help.
I figured out how to use application settings to save and load a single color, and this is the code for that-
MyBase.BackColor = Color.Green My.Settings.SavedColor = Color.Green
this works perfectly, but then when i try to do it with a background image, I use this-
Form1.BackgroundImage =
My.Resources.bg My.Settings.SavedBG = My.Resources.bg
and the My.Resources.bg in the second line has an error that reads-
Value of Type "System.Drawing.Bitmap" cannot be converted to 'String'.
my application setting I made for the backgrounds is SavedBG
Thanks! You rock
also how do i turn off the loader lock
sure, because the My.Settings.SavedBG is a string property. - the My.Resources.bg is another type.
What you should be doing is saving the string type of what "bg" is, such as the name of the background or whatever.
How are you loading the image from the resources
to load i just used
Form1.BackgroundImage =
My.Resources.b_bg
b_bg is my resource
also, the ToString didnt work...I have no idea why but it didnt
yes its set to string too...
maybe I dont have the right code that is saving the image in my SavedBG setting... do you know what that would be
I knew that wouldnt work ;-)
the reason is because you are getting back the type of the object as a string - not the actual object itself.