I am using an Ultragrid version 10.3 and have a datasource bound to the grid. I have it set to .update the data on afterrowupdate event. What I cannot figure out is when I edit a row, the row header shows the pencil icon and what I want to have happen is when I click on the row header it takes the row out of edit mode and saves the data (similar to an Access grid). I cannot find an Event that does this. Only way I get the afterrowupdate or beforerowupdate events to fire is when I either select a different row (if there is one) or select a different control on the form. Can I do this by clicking the row header?
Hello jcom39201,
The easiest way to achieve what you are looking for here would be if you set the UpdateMode of the UltraGrid to OnCellChangedOrLostFocus.
If you rely on the your current settings there is still a way to achieve what you are looking for. Create a bool flag in your application, set it to true or false regards of the current mouse position and if you are currently over a rowSelector your could update the ActiveUltraGridRow on UltraGrid click event. Please take a look at the code snippet below:
bool isRowSelector = false; private void ultraGrid1_Click(object sender, EventArgs e) { if (isRowSelector) { UltraGrid ug = sender as UltraGrid; ug.ActiveRow.Update(); } } private void ultraGrid1_MouseEnterElement(object sender, Infragistics.Win.UIElementEventArgs e) { if (e.Element is RowSelectorUIElement) { isRowSelector = true; } } private void ultraGrid1_MouseLeaveElement(object sender, Infragistics.Win.UIElementEventArgs e) { if (isRowSelector) { isRowSelector = false; } }
Please feel free to to let us know if you need any further assistance.
I tried the code above and it works good, but I only want to update the row if the pencil icon is showing in the row selector not every time the selector is clicked. Is there a way to determine if the activerow is in editmode or has changes?
Works great. Thanks!
There is DataChanged property of the row which determines whether a data in a cell or row has been changed, and one possible code snippet that you could use would be the following:
private void ultraGrid1_Click(object sender, EventArgs e) { if (isRowSelector) { UltraGrid ug = sender as UltraGrid; if (ug.ActiveRow.DataChanged) { ug.ActiveRow.Update(); } } }
Please feel free to let us know if there is anything else that we could assist you with.