Click here to Skip to main content
15,902,635 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi, is there a library, or component that allow be to display a 'matlab' type command window (with math functions) in my c# program that would allow the users to manipulate the data in a datagrid view?? similar to how I would manipulate a workspace in matlab via the command window?
Posted

1 solution

I believe the answer is "yes," and it's already in .NET for you.

Check out the System.Data library's DataTable.Compute method; I think you'll be as surprised as I was by seeing how easily you can perform arbitrary math calculations based on string input, even without it being associated with an instance of a DataTable.

I 'stumbled' across this technique here:[^].

According to the FrameWork docs, you can manipulate rows and columns of an instance of a DataTable in the string that DataTable.Compute consumes; this is something I have not tried myself, however.

For example, see the MS docs on DataColumn.Expression for examples of manipulating Columns.

Syntax reminds me a lot of Excel "cell-language."

Very nice to have this tool, if you have a limited set of maths you need to parse and execute without going to the trouble of using CodeDom and on-the-fly compilation and execution.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900