views:

114

answers:

1

I have a datatable that contains an entry for the volume of a sound. The user can pick from values 1-10 or choose 'auto', in which case the system handles it. Internally, this is represented as an integer, where 1-10 represent volume values and -1 means 'auto'. The application is localized, so the exact string for 'auto' will vary by language.

We'd like to bind a datagrid to this datatable, but have the ability the volume column before it is displayed and before user entries are made to the table. Somewhere I'd like to have a way to say

if (table_value == -1) display_value = "Auto";

Likewise, if the user enters a value of 'Auto', I'd like to map it to the internal representation of -1.

Put simply, I'd like to have a way to insert a layer between the internal data representation in a datatable and the displayed values in the datagrid.

Note - environment is C# / Windows Forms / .Net 2.0

A: 

ItemDataBound is the event you are looking for. It fires when each individual item is bound to the grid, you can insert your logic there.

Matthew Vines