Note that there are some explanatory texts on larger screens.

plurals
  1. POIssue with custom TypeConverter and nested properties in the designer
    primarykey
    data
    text
    <p>I'm trying to add a nested property to my custom control using a TypeConverter, here is my test code:</p> <pre><code>public class TestNestedOptionConverter : TypeConverter { public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] filter) { return TypeDescriptor.GetProperties(typeof(TestNestedOption)); } public override bool GetPropertiesSupported(ITypeDescriptorContext context) { return true; } } [TypeConverter(typeof(TestNestedOptionConverter))] public class TestNestedOption { bool test1 = false; [Description("TestParam1")] public bool Test1 { get { return test1; } set { test1 = value; } } [Description("TestParam2")] public int Test2 { get; set; } } public partial class UserControl1 : UserControl { public TestNestedOption TestOption { get; set; } public UserControl1() { InitializeComponent(); } } </code></pre> <p>When I add the control to a form, I see the TestOption property in the designer property grid, but the sub-properties do not show up at all (there isn't even an expansion box next to TestOption). </p> <p>My understanding of this is that it is supposed to sort of recursively call the <code>GetProperties()</code> method on each property, so as a test hack I put a <code>MessageBox.Show()</code> in the <code>TestNestedOptionConverter.GetProperties()</code> method, and I don't see the message when the designer loads the control. This makes me think that the overridden <code>GetProperties()</code> is never being called by the designer for some reason.</p> <p>Any ideas about what I am doing wrong?</p> <p>I'm using Visual Studio 2008.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload