I have a basic array of integers, 10x5 (10 rows) and I have a DataGridView displaying those values.
I go through the array and output the values to the appropriate DataGridView cell, I don't know how to link the DataGrid to the array, but that is not important.
I want to be able to change values in the first two columns of the DataGridView and therefore the array, but not the last 3.
The last 3 should do real-time calculations on the values in the previous columns and be effectively locked so I cannot change them.
Lest say column 0 has integers from 1-10 and column 1 is all 1s. Column 2 should be the sum of the previous 2 values in column 0 times the value in column 1. (obviously for row 0 there is not previous row so it only takes the values from row 0.
Then column 4 does calculations based on values in columns 0, 1 and 2, and so on.
This is easy to do in excel with simple formulas. Then I lock the formula cells and change the first 2 columns at will.
I my calculation I go through the array to do my calculation which is fine, but I don't know how to take data from the gridview that I enter into the array, calculate and display the results in the gridview.
This should all be done in real time, and if at all possible I would like the application to still keep running while I am editing (unlike Excel).
Also, I think excel knows which cells were changed and only recalculated what it needs, I co though the entire array even if I don't need to, is there a way to optimize my calculation. The data I am using is small, 10x10 max but I still would like to optimize it.
Also, as another link to excel, I need know when the values of the last 3 columns change as other parts of the code use that value. I can use events, however, I am not sure how to send an event for each cell. Would I need each cell have it's own event change generator which means I need to have at least 30 checks on every update? Anybody know how excel does it, I can't believe it was efficient for someone to write 2^16*256 events, and that is only for pre 2008 versions.
I know this is quite a few questions, please answer or help anywhere you can.
I an nutshell, I am trying to clone a small excel sheet efficiently and use the result from code.
Thanks, elkinm.
I go through the array and output the values to the appropriate DataGridView cell, I don't know how to link the DataGrid to the array, but that is not important.
I want to be able to change values in the first two columns of the DataGridView and therefore the array, but not the last 3.
The last 3 should do real-time calculations on the values in the previous columns and be effectively locked so I cannot change them.
Lest say column 0 has integers from 1-10 and column 1 is all 1s. Column 2 should be the sum of the previous 2 values in column 0 times the value in column 1. (obviously for row 0 there is not previous row so it only takes the values from row 0.
Then column 4 does calculations based on values in columns 0, 1 and 2, and so on.
This is easy to do in excel with simple formulas. Then I lock the formula cells and change the first 2 columns at will.
I my calculation I go through the array to do my calculation which is fine, but I don't know how to take data from the gridview that I enter into the array, calculate and display the results in the gridview.
This should all be done in real time, and if at all possible I would like the application to still keep running while I am editing (unlike Excel).
Also, I think excel knows which cells were changed and only recalculated what it needs, I co though the entire array even if I don't need to, is there a way to optimize my calculation. The data I am using is small, 10x10 max but I still would like to optimize it.
Also, as another link to excel, I need know when the values of the last 3 columns change as other parts of the code use that value. I can use events, however, I am not sure how to send an event for each cell. Would I need each cell have it's own event change generator which means I need to have at least 30 checks on every update? Anybody know how excel does it, I can't believe it was efficient for someone to write 2^16*256 events, and that is only for pre 2008 versions.
I know this is quite a few questions, please answer or help anywhere you can.
I an nutshell, I am trying to clone a small excel sheet efficiently and use the result from code.
Thanks, elkinm.