tags:

views:

706

answers:

3

Is there an easy way to wrap a "Preferences Panel" thing around the Settings.settings file (or any other settings file)?

Basically I have a bunch of strings stored in Settings.settings, and want to have a form where the user can edit these..

I could add a bunch of TextBoxes, and have a button that does Properties.blah = this.blahInput.Text; Properties.Save(); for each, but this feels like reinventing the wheel..

Edit: The PropertyGrid control (as suggested by bassfriend's) seems perfect, but I cannot work out how to bind the property grid's SelectedObject to Properties.Settings.Default - When I try I get the following error:

Cannot implicitly convert type 'MyProject.Properties.Settings' to 'object[]'
+5  A: 

Maybe you want to take a look at the PropertyGrid Control.

bassfriend
For the record - there is also a WPF PropertyGrid over at CodePlex http://www.codeplex.com/wpg
Peter Lillevold
+1  A: 

I had no problem:

        propertyGrid1.SelectedObject = Properties.Settings.Default;

I did have to change the visibility to Public in the Settings Designer.

John Saunders
Opps, I was trying to set "SelectedObjects", not "SelectedObject".. Thanks!
dbr
A: 

Maybe you need to use the Settings.Default.Properties property? That returns SettingsPropertyCollection which should be convertable to an object[].

Alan McBee
Nah, I was trying to set "SelectedObjects", not the singular "SelectedObject"..
dbr