Example #1
0
        private static void propertyGrid_PropertyValueChanged(object sender,
                                                              PropertyValueChangedEventArgs e)
        {
            PropertyGrid   grid           = sender as PropertyGrid;
            CollectionForm collectionForm = (CollectionForm)grid.Parent.Parent;

            NamedList <T> items           = collectionForm.EditValue as NamedList <T>;
            GridItem      changedGridItem = e.ChangedItem;

            while (changedGridItem.GridItemType != GridItemType.Root)
            {
                changedGridItem = changedGridItem.Parent;
            }

            T changedItem = (T)changedGridItem.Value;

            if (e.ChangedItem.PropertyDescriptor.Name == "Name")
            {
                foreach (T item in items)
                {
                    if (item.Equals(changedItem))
                    {
                        continue;
                    }

                    if (String.Equals(item.Name, changedItem.Name))
                    {
                        changedItem.Name = e.OldValue as string;
                    }
                }
            }
        }
Example #2
0
        /// <summary>
        /// Creates a <see cref="NamedList{T}"/> from this enumeration.
        /// </summary>
        /// <typeparam name="TSource">The type of the source.</typeparam>
        /// <param name="source">The source.</param>
        /// <returns></returns>
        public static NamedList <TSource> ToNamedList <TSource>(this IEnumerable <TSource> source) where TSource : INamed
        {
            NamedList <TSource> collection = new NamedList <TSource>();

            foreach (TSource item in source)
            {
                collection.Add(item);
            }

            return(collection);
        }
Example #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="NamedListPropertyDescriptor{T}"/> class.
 /// </summary>
 /// <param name="list">The named list.</param>
 /// <param name="index">The index.</param>
 public NamedListPropertyDescriptor(NamedList <T> list, int index)
     : base("#" + index.ToString(), null)
 {
     this._collection = list;
     this._index      = index;
 }