Custom types of ApplicationSettingsBase not expandable in property grid

Hi,

How can I make the TestSettings class (below) browsable/expandable in the property grid, when it acts as a property of EngineSettings

The code below does not work...what might be wrong

[TypeConverterAttribute(typeof(ExpandableObjectConverter))]

[Category("Engine Settings")]

[Description("Settings for the Engine")]

sealed class EngineSettings: ApplicationSettingsBase

{

[UserScopedSetting]

public TestSettings TestSettings

{

get { return (TestSettings)this["TestSettings"]; }

set { this["TestSettings"] = value; }

}

}

[TypeConverterAttribute(typeof(ExpandableObjectConverter))]

internal class TestSettings : ApplicationSettingsBase

{

[UserScopedSetting]

public String Test

{

get { return (String)this["Test"]; }

set { this["Test"] = value; }

}

[UserScopedSetting]

public int Number

{

get { return (int)this["Number"]; }

set { this["Number"] = value; }

}

}

Thanks!



Answer this question

Custom types of ApplicationSettingsBase not expandable in property grid

  • Sumabobby

    You can set the PropertyGrid.SelectedObject property with the object you want to display, in your situation it should be and instance of a EngineSettings class.


  • VirGin

    Oh, you mean like PropertyGrid.SelectedObject = mEngineSettings

    -I've already done that, and that's not the problem. The properties of EngineSettings are displayed correctly. I probably haven't explained my problem well enough:

    The thing is that I am unable to expand the TestSetting-property of the EngineSettings class. Meaning that if I have custom class types as properties, I am unable to expand this property to change the lower-level properties of TestSetting like the "String Test" property and the "int Number" property.

    Only the 1st level properties of EngineSettings are accessible, even when I've set the [TypeConverterAttribute(typeof(ExpandableObjectConverter))] for the TestSetting class.

    Any idea why the ExpandableObjectConverter doesn't work when setting PropertyGrid.SelectedObject to an object that inherits ApplicationSettingsBase (If that is actually my problem)

    (I have changed both the "sealed" and the "internal" keywords to "public" now)

    Thanks again!


  • Praval Rastogi

    Sorry if this is a stupid question, but do you have a code-snippet showing how to bind the EngineSettigns to the property grid

    -I haven't managed to figure out how to do that yet...


  • Paul Huizer

    Oke, i will close this thread because the first question is answered and this will help other users. But because your expaination is better in the other thread we will discusse it there.

    Unable to expand child properties in PropertyGrid using Properties.Settings


  • Parham.G

    I have made a new thread that probably explains my problem clearer. And I discovered that the same problem occurs when trying to edit the Properties.Settings in a PropertyGrid: http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=326753&SiteID=1
  • hazel_m_stu_o

    Just bind the EngineSettings to the property grid and it will be showed as an property member if your TestSettings is a public class.

    This code wouldn't complite because the TestSettings class has a internal scope and the EngineSettings.TestSettings property an public scope.


  • Custom types of ApplicationSettingsBase not expandable in property grid