Create PropertyEditor for Grid.Columns property.

Sep 27, 2010 at 2:14 PM

I didn't see any  propertyeditor for the grid.Columns property, so I decide creating it by myself.

What's wrong with the following code :

When I put my grid on a form, I can open the propertyEditor,

but I didn't succeed to add any column by the editor (the "add" combobox is either disabled nor no list behind it).

 

... Thanks.

===========================

using System;

using System.Linq;

using System.Collections.Generic;

using System.Text;

using System.ComponentModel.Design;

using System.Windows.Forms;

using System.Windows.Forms.Design;

 

using SourceGrid.Cells;

 namespace

SourceGrid

{

 

class GridColumnsEditor : CollectionEditor

 

 

{

 

public GridColumnsEditor(Type type) :base(type)

{ }

 

protected override Type CreateCollectionItemType()

{

 return typeof(ICell);

}

 

protected override Type[] CreateNewItemTypes()

{

 

Type[] types = new Type[] { typeof(Cells.Button),

 

typeof(Cells.CheckBox),

 

typeof(Cells.ColumnHeader),

 

typeof(Cells.Image),

 

typeof(Cells.Link),

 

typeof(Cells.RichTextBox)

};

 

return types;

}

 

protected override object CreateInstance(Type itemType)

{

 

GridColumn column =
itemType.GetConstructor(Type.EmptyTypes).Invoke(null) as   GridColumn;

 return column;

}

}

}