110,571
社区成员
发帖
与我相关
我的任务
分享
public class MyUITypeEditor : CollectionEditor
{
public MyUITypeEditor(Type type)
: base(type)
{ }
protected override Type[] CreateNewItemTypes()
{
Type[] types = new Type[] { typeof(DataGridViewTextBoxColumn),
.....
};
return types;
}
}
[EditorAttribute(typeof(ColumnEditor), typeof(System.Drawing.Design.UITypeEditor))]
public ColumnCol Columns
{
get
{
return this.m_Columns;
}
}
internal class ColumnEditor : UITypeEditor
{
public override System.Drawing.Design.UITypeEditorEditStyle GetEditStyle(System.ComponentModel.ITypeDescriptorContext context)
{
return UITypeEditorEditStyle.Modal;
}
public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, System.IServiceProvider provider, object value)
{
IWindowsFormsEditorService edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
if (edSvc != null)
{
ColumnEditorForm f = new ColumnEditorForm();
f.ColumnCol = value as ColumnCol;
f.StartPosition = FormStartPosition.CenterParent;
edSvc.ShowDialog(f);
}
return value;
}
public override bool GetPaintValueSupported(System.ComponentModel.ITypeDescriptorContext context)
{
return false;
}
}
public DataGridViewColumnCollection MyColumns
{
get {
return this.dataGridView1.Columns;
}
}