I am trying to make it so that when my C# application closes, it will save the window's size and location to the registry, then on startup it will change the window to those sizes. I am getting an error when I try it this way:
Microsoft.Win32.RegistryKey key;
key = Microsoft.Win32.Registry.CurrentUser.CreateSubKey("Software\\Pandora");
//key.SetValue("Size", this.Size);
//key.SetValue("Location", this.Location);
//key.SetValue("Browser", Browser.Location);
this.Size = new System.Drawing.Size(key.GetValue("Size").ToString());
key.Close();
What do I need to do to set this.size to the "Size" Value?
==EDIT==
With
this.Size = new System.Drawing.Size(key.GetValue("Size").ToString(), Microsoft.Win32.RegistryValueKind.String);
I get the errors:
Error 1 The best overloaded method match for 'System.Drawing.Size.Size(int, int)' has some invalid arguments C:\Users\Sean\Documents\Visual Studio 2010\Projects\Pandora\Pandora\Form1.cs 23 25 Pandora
Error 2 Argument 1: cannot convert from 'string' to 'int' C:\Users\Sean\Documents\Visual Studio 2010\Projects\Pandora\Pandora\Form1.cs 23 49 Pandora
Error 3 Argument 2: cannot convert from 'Microsoft.Win32.RegistryValueKind' to 'int' C:\Users\Sean\Documents\Visual Studio 2010\Projects\Pandora\Pandora\Form1.cs 23 82 Pandora
If I change it to:
this.Size = new System.Drawing.Size(key.GetValue("Size").ToString());
The result is
Error 1 The best overloaded method match for 'System.Drawing.Size.Size(System.Drawing.Point)' has some invalid arguments C:\Users\Sean\Documents\Visual Studio 2010\Projects\Pandora\Pandora\Form1.cs 23 25 Pandora
Error 2 Argument 1: cannot convert from 'string' to 'System.Drawing.Point' C:\Users\Sean\Documents\Visual Studio 2010\Projects\Pandora\Pandora\Form1.cs 23 49 Pandora
And
this.Size = new System.Drawing.Size(key.GetValue("Size"));
Gives me
Error 1 The best overloaded method match for 'System.Drawing.Size.Size(System.Drawing.Point)' has some invalid arguments C:\Users\Sean\Documents\Visual Studio 2010\Projects\Pandora\Pandora\Form1.cs 23 25 Pandora
Error 2 Argument 1: cannot convert from 'object' to 'System.Drawing.Point' C:\Users\Sean\Documents\Visual Studio 2010\Projects\Pandora\Pandora\Form1.cs 23 49 Pandora