Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
2715
Grid commit row
posted

Hi!

I'm having an issue : i have a form with a grid on it. The grid can be edited, and the behaviour i need is the following : when editing a cell, if the Esc key is pressed i want the grid to commit the row and display a message.

At this moment the grid loses the newly entered data and return to the initial value when esc is pressed.

Here's how i've implemented (the isEditMode is a flag for when the grid is in edit mode, and HasModifiedValues is a flag that gets set to true on BeforeCellUpdate)

void ulgGrid_KeyUp(object sender, KeyEventArgs e) {

            if (e.KeyCode == Keys.Escape) {

                if (IsEditMode) {

                    ulgGrid.PerformAction(UltraGridAction.CommitRow);

                    if (HasModifiedValues) {

                        if (MessageBox.Show("You have some unsaved changes. Are you sure you want to roll them back?", "Warning!", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes) {

                            CancelModifications();

                        }

                    }

                }

                if (IsEditMode && !HasModifiedValues) {

                    CancelModifications();

                }

            }

        }

 

Thank you!

Parents Reply Children
No Data