DataGridView calculated field

  • Thread starter Thread starter Aleksey Timonin
  • Start date Start date
A

Aleksey Timonin

Hi guys,
I have a DataGridView binded to DataTable.
In the DataTable I have an "ID" field.
How can I create calculated column in the DataGridView that gets as value
object (string) from my list, where item index in the list is equal to value
in "ID" field?

Thanks a lot
Aleksey
 
So you have an ID field, and in the background you have a list with all the
items, and want to show the value that goes with the ID?

You could use a DataGridViewComboBoxColumn and bind it.

You could also use the Format and Parse events on the cells of the
datagridview. Check the column index, and if it's the right column, in the
Format event you would get the description and show it in the grid; in the
Parse event you would take the description and get the corresponding ID.

There's a great example of this in Brian Noyes's Data Binding Book.

RobinS.
 
Back
Top