Hi all,
I have a ultragrid with 80+column, so I use the KeyDown function to make it able to move like excel with ArrowKey and also mouse. To convinient for modify, I would like to let them direct key in and modify then when move to next field and direct update the previous updated value into DB.
How can I grap which cell/field which been modified? Because I want to allow them to update field by mouse clicking to it and also keyboard arrowkey, so I wasnt sure which function is more suitable for this scenario.
Please guide.
Thank you very much!
Hi,
It depends on what kind of information you want to track and exactly when you are trying to use that information. But it sounds like what you are trying to do is track any changes that are made to the data so that you can build an Update command for your data source. In other words, you are concerned with the updating of the back end by the data source.
The grid is really not involved in this process. The grid only deals with it's local DataSource. The interaction between the DataSource and the back end is something that is typically handled outside the grid.
What kind of DataSource are you using for your grid? If you are using a DataSet or DataTable, then these objects track all changes for you, and the DataAdapter can utilize this information and build your SQl statements for you.
If you are using some other data source, then you need to investigate what kind of support that data source has for tracking changes.
If you really have to, you could build a list of changes yourself by using the events of the grid. But this assumes that the grid is the only thing that will ever change the data. And there is no functionality built-in to the grid to do this for you.
Hi Mike,
I have a screen like this (see below), so I would like to grap which column user updated (from TF_1 until TF_79) and the value it update, then i can direct assign into the update statement.
Let say I update row2 TF_3 to 2, then i able capture is TF_3 to variable column and 2 assign to variable value, then assign to "update table set ' "+column+" ' = ' "+value+" ' " something like that. then when i click arrow key --> to TF_4 then it will fire and run the update statement immediately.
Any function I can use to get the column name and also the value once it update (may update more than field) and any function should I use, once the field been modified and it will directly run the update function like I mention above.
Hope you able to understand what I trying to ask.
AfterCellUpdate fires after the user makes a change to a cell and the the grid commits those changes to the underlying data source. When the change is committed is determined by the UpdateMode property. Updates can also be triggered in code via the Update method of the row or the UpdateData method of the grid.
I'm having a hard time understanding your question, though. Can you explain in more detail exactly what you want to do?
Hi Torrey,
Thanks for reply. The function you mention able to capture more than 1 field with the column name and also the value? because I need to capture the column name also the value for my update query, so only those field been modified will be updated.
I had done some research online, notice that most of them using AfterCellUpdate, will it suitable for my case? If possible, can you explain with example how does it work?
Thank you very much!~
If I understood you correctly then the UpdateMode property would be useful in your scenario. With the line of code pasted below, it will commit the changes to the data source when the user leaves a modified cell.
ultraGrid1.UpdateMode = UpdateMode.OnCellChange;