How? Using a custom TypeConverter in custom grid column style.

  • Thread starter Thread starter Lee Gillie
  • Start date Start date
L

Lee Gillie

I have bound a grid column to an enumeration data type.

I derive from DataGridTextBoxColumn and override GetColumnValueAtRow and
call a function I wrote to convert the enumeration value to a
descriptive text for display in the grid cell. This works well.

Even though the grid is not editable, and the column is readonly, when
one clicks on the cell I get a type conversion exception. Looking at the
stack I see Edit calls GetText which uses an "EnumConverter" to convert
the descriptive text to an int32, which ultimately tries to parse the
descriptive as an int32, and of course fails.

I see that DataGridTextBoxColumn has a PRIVATE type converter member.

I am seeking any pointers to examples, or samples, or explanations of
how to intercede the conversion of the descriptive back to an enumerated
value for my custom column type. I think I need to implement a type
converter, but I don't see how to tie it in. Or even just to know "it
can't be done" would be helpful.
 
Hi Lee,

If your column is planned to be always read-only, the simplest solution
would be to override the Edit method and to provide an empty implementation.
 
Back
Top