Search code examples
.netwinformsdatatabledatacolumn

Customize DataColumn.Expression handling in C#


I would like to change behavior of DataColumn.Expression so that when I write:

DataColumn.Expression = "MyMethod(Price)"

It will call MyMethod, pass value from Price column into it and display evaluated value.

How can I acomplish this?


Solution

  • Not possible. The expression parser behind the Expression property is simple and not extensible. Making arbitrary function calls is not one of its capabilities. There are several ways to work around this, especially ones that don't require an expensive reflection lookup. Consider the DataTable.RowChanged event for example.