Здравствуйте, AlexSychev, Вы писали:
AS>Ссылка не очень информативная, наступал на теже грабли, а тема что тебе нужна уже обсуждалась на форуме.
AS>Помоему решения я нашел имеено здесь.
AS>вот как это у меня получилось
AS>1) сам объект
AS> [TypeConverter(typeof(InputFieldConverter))]
AS> public class InputField
AS> {
AS> private string _name = "";
AS> private string _label = "";
AS> public InputField()
AS> {
AS> }
AS> public InputField(string name, string label)
AS> {
AS> _name = name;
AS> _label = label;
AS> }
AS> [DefaultValue("")]
AS> public string Name
AS> {
AS> get { return _name; }
AS> set{ _name = value; }
AS> }
AS> [DefaultValue("")]
AS> public string Label
AS> {
AS> get { return _label; }
AS> set{ _label = value; }
AS> }
AS> }
AS>2) типизированная коллекция
AS> public class InputFieldCollection : CollectionBase
AS> {
AS> public int Add(InputField inputField)
AS> {
AS> return InnerList.Add( inputField );
AS> }
AS> public InputField this[int index]
AS> {
AS> get { return (InputField)InnerList[index]; }
AS> set { InnerList[index] = value; }
AS> }
AS> public void AddRange(InputField[] inputFields)
AS> {
AS> InnerList.AddRange(inputFields);
AS> }
AS> }
AS>3) и обязательный TypeConverter для InputField (взято из MSDN, см InstanceDescriptor Class [C#])
AS> internal class InputFieldConverter : TypeConverter
AS> {
AS> // This method overrides CanConvertTo from TypeConverter. This is called when someone
AS> // wants to convert an instance of Triangle to another type. Here,
AS> // only conversion to an InstanceDescriptor is supported.
AS> public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
AS> {
AS> if (destinationType == typeof(InstanceDescriptor))
AS> {
AS> return true;
AS> }
AS> // Always call the base to see if it can perform the conversion.
AS> return base.CanConvertTo(context, destinationType);
AS> }
AS> // This code performs the actual conversion from a Triangle to an InstanceDescriptor.
AS> public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
AS> {
AS> if (destinationType == typeof(InstanceDescriptor))
AS> {
AS> ConstructorInfo ci = typeof(InputField).GetConstructor(new Type[]{typeof(string), typeof(string)});
AS> InputField t = (InputField) value;
AS> return new InstanceDescriptor(ci,new object[]{t.Name, t.Label});
AS> }
AS> // Always call base, even if you can't convert.
AS> return base.ConvertTo(context, culture, value, destinationType);
AS> }
AS> }
Странно, мне не помогло.

... << RSDN@Home 1.1.4 stable SR1 rev. 568>>