S
simion tishler via .NET 247
Hey I have created a collection that inherits from theCollectionsBase that take a columnheader as it's input. I havethen created an intance of the collections class and provided aproperty to it through my usercontrol. The property uses thecollections editor attribute to expose the collections editor atdesign time when I'm using my user control. When I click on thecollections property through the desgner the editor pops up butit only displays a Systems.Object property and not all theproperties of a column header. This is all pretty complex I knowand if I have come this far I should be able to continue. I canbut I just want to take the pain out of it if someone know theanswer.
here is the code for the collection
public class ColumnCollection :System.Collections.CollectionBase
{
public ColumnCollection()
{
}
public void Add(ColumnHeader column)
{
List.Add(column);
}
public void Remove(int index)
{
// Check to see if there is a widget at thesupplied index.
if (index > Count - 1 || index < 0)
// If no widget exists, a messagebox isshown and the operation
// is cancelled.
{
System.Windows.Forms.MessageBox.Show("Index not valid!");
}
else
{
List.RemoveAt(index);
}
}
public ColumnHeader Item(int Index)
{
// The appropriate item is retrieved from theList object and
// explicitly cast to the Widget type, thenreturned to the
// caller.
return (ColumnHeader) List[Index];
}
}
here is the code for the property in the user control
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)
,EditorAttribute("typeof(CollectionEditor)","typeof(System.Drawing.Design.UITypeEditor)")]
public ColumnCollection ColumnsCollection
{
get
{
return columnscollection;
}
set
{
columnscollection = value;
}
}
here is the code for the collection
public class ColumnCollection :System.Collections.CollectionBase
{
public ColumnCollection()
{
}
public void Add(ColumnHeader column)
{
List.Add(column);
}
public void Remove(int index)
{
// Check to see if there is a widget at thesupplied index.
if (index > Count - 1 || index < 0)
// If no widget exists, a messagebox isshown and the operation
// is cancelled.
{
System.Windows.Forms.MessageBox.Show("Index not valid!");
}
else
{
List.RemoveAt(index);
}
}
public ColumnHeader Item(int Index)
{
// The appropriate item is retrieved from theList object and
// explicitly cast to the Widget type, thenreturned to the
// caller.
return (ColumnHeader) List[Index];
}
}
here is the code for the property in the user control
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)
,EditorAttribute("typeof(CollectionEditor)","typeof(System.Drawing.Design.UITypeEditor)")]
public ColumnCollection ColumnsCollection
{
get
{
return columnscollection;
}
set
{
columnscollection = value;
}
}