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.

Re: How? Using a custom TypeConverter in custom grid column style. by Dmytro

Dmytro
Fri Jun 17 01:23:15 CDT 2005

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.

--
Sincerely,
Dmytro Lapshyn [Visual Developer - Visual C# MVP]


"Lee Gillie" <Lee@nospam.odp.com> wrote in message
news:uI8RLwocFHA.2520@TK2MSFTNGP09.phx.gbl...
>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.