microsoft / winforms-designer-extensibility

MIT License
56 stars 13 forks source link

Custom public properties on a Form type do not show in PropertyGrid of designer #16

Closed pallibj closed 1 year ago

pallibj commented 1 year ago

Steps to reproduce:

  1. Create a new form and add a simple public property on it, say "public string Test {get; set;}"
  2. Rebuild and open form in designer.
  3. The new property is not shown in the PropertyGrid.

Now, repeat the same with a UserControl:

  1. Create new UserControl and add the same simple property Test.
  2. Create new Form and drop the new UserControl on the form.
  3. Rebuild and open form in designer.
  4. The new property is now shown in the PropertyGrid for the UserControl.

Palli

KlausLoeffelmann commented 1 year ago

Well, in the first case, the Form is only being built at the moment, so what you see on the screen at design time, is the base class of that Form, and that of course does not have the property at that point.

In contrast, if you have built a UserControl, and use it in a Form, then the UserControl has been built. And therefore, it has the property.

This is By Design, and it is exactly how the classic Framework Designer also works.