views:

35

answers:

1

I want a slight variation of the custom cell example from the MS website

How to: Customize Cells and Columns in the Windows Forms DataGridView Control by Extending Their Behavior and Appearance

by passing an argument to the custom cell constructor so I could use it later, namely to evaluate something when painting the cell.

Private _o as MyObject
Public Sub New(ByVal o As MyObject)
MyBase.New()
_o = o
End Sub

but then when I run the code it throws and exception

MissingMethodException occured
No parameterless constructor defined for this object.

Does this mean that custom cells must have a parameterless constructor?

Thanks.

A: 

At a guess, the table is going to use reflection (Activator.CreateInstance) to create instances of the cell on a per-row basis; so yes - it will need a public parameterless constructor to do that.

Marc Gravell