Excel-like Expressions in DataGridView

In Excel, I can use an expression like "= C16 + C17" for a cell to display values ​​from other cells.

In my application, I need something like this. The user should be able to select a range of cells from the data splitting process and display the amount in another cell (not in the footer!). So I need to be able to assign something like "Take values ​​from column xyz from records identified by IDs 7, 23, 42 and sum them" with an arbitrary cell.

Does anyone know of a component that offers such an "expression language"?

+1


source to share


2 answers


I'm going to move on to this CodeProject article: Implementing an Excel Formatted Engine . It has a parser, formula evaluation, and it's pretty easy to hook it up using a datagrid.



+1


source


There is nothing built into the DataGridView that can help you with this. Your option is of course custom controls. I'm sure Infragistics UltraGrid has something like that, but in case you don't want to spend money, you can roll up yourself. It's actually not that hard. Here's an easy way to do it.

Always bind your datagridview to a DataTable and then when you want to add an expression, you add a new DataColumn and set the Expression property. Here is some information about the DataColumn expression property. From MSDN



We've done something that looks like work and it actually works really well. Good luck!

+2


source







All Articles