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!
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;
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!~
Hi,
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 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.
I found the way for my problem. Thanks all.
Is solved now.
Thanks for all guidance ^^
I try to get the updated cell with AfterCellUpdate and assign it into variable as part of my update statement, but it execute the update until the application "no respone". Please point out my mistake for better improvement.
private void ugLisfOfVolMaint_AfterCellUpdate(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs e)
{ // AfterCellUpdate gets fired after the cell's value has been changed in the UltraGrid.
const string METHOD_NAME = "mnuShowStructure_Click";
Cursor oldCursor = Cursor.Current;
Cursor.Current = Cursors.WaitCursor;
string strSQL, svolID = "", svolLine = "", srouteID = "",sheader ="", svalue ="";
try
{
svolID = ugLisfOfVolMaint.ActiveRow.Cells["vol_id"].Value.ToString();
svolLine = ugLisfOfVolMaint.ActiveRow.Cells["vol_line_id"].Value.ToString();
srouteID = ugLisfOfVolMaint.ActiveRow.Cells["Route_ID"].Value.ToString();
sheader = e.Cell.Column.ToString();
svalue = e.Cell.Value.ToString();
strSQL = "update ras_vol_wafer set " + sheader + " = '" + svalue + "', last_update = sysdate " +
" where vol_id = '" + svolID + "' and vol_line_id = '" + svolLine + "' and rrth_id = '" + srouteID + "' ";
MyDBConn.ExecuteNonQuery(ModGloVariable.RasmusConn, CommandType.Text, strSQL);
}
catch (Exception ex)
ModProc.ShowSysErrMsg(ex.Message, METHOD_NAME, CLASS_NAME);
finally
Cursor.Current = oldCursor;
UltraDataSource doesn't have any back end, it only exists in the client. So it does not track changes.
But I think I am probably not understanding your question. Leaving a cell in the grid will automatically write any changes to the data source. This depends on the UpdateMode property, but updating on a cell change is the default.
I don't think I understand your question or what you are trying to do.
Im using UltraWinDataSource