Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>My assumption was that your form becomes visible before the Configuration property was assigned. You didn't supply enough code to see if that was the case. In order to test out my concern, I created two configuration objects:</p> <pre><code>public class Configuration1 { public string Test { get; set; } public byte Test1 { get; set; } public int Test2 { get; set; } } </code></pre> <p>and</p> <pre><code>public class Configuration2 { public char Test3 { get; set; } public List&lt;string&gt; Test4 { get; set; } } </code></pre> <p>I modified your camera class to look like this:</p> <pre><code>public class Camera { public Camera() { Configuration1 = new Configuration1(); Configuration2 = new Configuration2(); } private object configuration; [TypeConverter(typeof(ExpandableObjectConverter))] public object Configuration { get; set; } [TypeConverter(typeof(ExpandableObjectConverter))] public Configuration1 Configuration1 { get; set; } [TypeConverter(typeof(ExpandableObjectConverter))] public Configuration2 Configuration2 { get; set; } } </code></pre> <p>I then created a form with a PropertyGrid and two Button instances. I configured the form interactions like this:</p> <pre><code>public partial class Form1 : Form { private readonly Camera camera = new Camera(); public Form1() { InitializeComponent(); propertyGrid1.SelectedObject = camera; } private void Button1Click(object sender, System.EventArgs e) { camera.Configuration = new Configuration2(); UpdatePropertyGrid(); } private void Button2Click(object sender, System.EventArgs e) { camera.Configuration = new Configuration1(); UpdatePropertyGrid(); } private void UpdatePropertyGrid() { propertyGrid1.Refresh(); propertyGrid1.ExpandAllGridItems(); } } </code></pre> <p>The startup view looks like this:</p> <p><img src="https://i.stack.imgur.com/47271.jpg" alt="enter image description here"></p> <p>After clicking the first button:</p> <p><img src="https://i.stack.imgur.com/ZNMfv.jpg" alt="enter image description here"></p> <p>After clicking the second button:</p> <p><img src="https://i.stack.imgur.com/fzUta.jpg" alt="enter image description here"></p> <p>If you remove the refresh, the property grid does not work correctly. The alternative is to supply an interface with INotifyPropertyChanged on your classes and properties.</p>
    singulars
    1. This table or related slice is empty.
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      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