Sometimes we need to edit aggregated property - I mean the property that represents object with few properties .The simple way to do this - we can use TypeConverter with ExpandableObjectConverter as shown in the example
[TypeConverter(typeof(ExpandableObjectConverter))]
public class FullName
{
private string _FirstName;
private string _LastName;
public FullName(string _FirstName, string _LastName)
{
this._FirstName = _FirstName;
this._LastName = _LastName;
}
[DisplayName("First Name")]
[Description("First name of the person")]
public string FirstName
{
get
{
return _FirstName;
}
set
{
_FirstName = value;
}
}
[DisplayName("Last Name")]
[Description("Last name of the person")]
public string LastName
{
get
{
return _LastName;
}
set
{
_LastName = value;
}
}
///<summary>
///Returns a <see cref="T:System.String"></see>
/// that represents the current <see cref="T:System.Object"></see>.
///</summary>
///
///<returns>
///A <see cref="T:System.String"></see>
/// that represents the current <see cref="T:System.Object"></see>.
///</returns>
///<filterpriority>2</filterpriority>
public override string ToString()
{
return _FirstName + " " + _LastName;
}
}
[DisplayName("Full Name")]
[Description("Full name of the person")]
public FullName FullName
{
get
{
return _FullName;
}
set
{
_FullName = value;
}
}
Result - the editor for aggregated object
1 comment:
Your code does not work.
Post a Comment