class LLUserControlCell : DataGridViewTextBoxCell { Type thisType; public void EditingType(Type t) { set {thisType = value;} get { return thisType;} public override Type EditType { get { return thisType; } } public override Object Clone() { LLUserControlCell c = (LLUserControlCell) base:Clone(); c.EditingType = this.EditingType; } } //Then: LLUserControlCell ucc = new LLUserControlCell(); ucc.EditingType = Type.GetType("myClass"); DataGridViewColumn dgvc = new DataGridViewColumn(ucc);>I've subclassed a DataGridViewCell thus:
class LLUserControlCell : DataGridViewTextBoxCell > { > Type thisType; > public void SetEditType(Type t) > { > thisType = t; > } > > public override Type EditType > { > get { return thisType; } > } > } >Then I use:
>LLUserControlCell ucc = new LLUserControlCell(); >ucc.SetEditType(Type.GetType("myClass")); >DataGridViewColumn dgvc = new DataGridViewColumn(); >dgvc.CellTemplate = ucc;When I add this column to a DataGridView at runtime all looks well (the Datacolumns CellTemplate.EditType returns the expected type) but the actual cells in the column return null for the EditType. Other specific property settings of the CellTemplate (e.g. ToolTipText) are preserved. Can this be done (and, if not, is there any way to avoid having to create subclassed DataGridViewCells for each required UserControl type) ?