111,098
社区成员




private void Form1_Load(object sender, EventArgs e)
{
this.propertyGrid1.SelectedObject = new My();
}
public class My
{
public int Count { get; set; }
[CategoryAttribute("坐标"), TypeConverter(typeof(MyNameConverter))]
public string Name { get; set; }
private class MyNameConverter : StringConverter
{
public override TypeConverter.StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
{
if (context != null && context.Instance is My)
{
List<string> values = new System.Collections.Generic.List<string>();
values.Add("改变Count,改变列表");
for (int i = 0; i < (context.Instance as My).Count; i++)
{
values.Add((i + 1).ToString());
}
return new StandardValuesCollection(values);
}
return base.GetStandardValues(context);
}
public override bool GetStandardValuesSupported(ITypeDescriptorContext context)
{
return true;
}
}
}