PropertyGrid control + array of custom objects
See the question and my original answer on StackOverflowFor the fist question, the easiest way is to add a "fake" property computed from the "real" property. It's not perfect, but you can use various attribute to help:
- DisplayName to give the fake property the name of the real property
- Browsable(false) instructs the property grid to skip the real property
EditorBrowsable(never) instructs Visual Studio's intellisense to not show this property in external code.
[Browsable(false)] public ParameterObject[] Parameters { get { return _parameters; } set { _parameters = value; } } [Category("SubReportParams"), DisplayName("Parameters")] [EditorBrowsable(EditorBrowsableState.Never)] public ParameterObject[] NonEmptyParameters { get { return _parameters.Where(p => p != null).ToArray(); } }
For the second question, one simple way is to add a ToString() implementation like this:
public class ParameterObject
{
public override string ToString()
{
return Name;
}
}
Otherwise, you can to add a custom TypeConverter to the class.