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
WinGrid BeforeCellUpdate problem
posted

Hi!

I'm trying to implement the following behaviour. I have an editable grid - if the user changes a value i want to show him a warning with the posibility of accepting or canceling that change. This is how i implemnted it :

 

void grid_BeforeCellUpdate(object sender, BeforeCellUpdateEventArgs e) {

 

            if (grid.ActiveCell.Column.Key == "COL") {

                try {

 

                    MessageBoxButtons btns = MessageBoxButtons.YesNo;

                    if (MessageBox.Show("If you change this all child values will be erased automatically. Are you sure you want to do this ? ", "Warning", btns) == System.Windows.Forms.DialogResult.No) {

                        e.Cancel = true;

                    }

                    else {

                        UpdatedContractRows.Add(e.Cell.Row);

                    }

 

                }

                catch (Exception ex) {

                    MessageBox.Show(ex.Message);

                    e.Cancel = true;

                }

            }

        }

 

 

The problem is the following - if i click yes, the value is commited and it changes in the cell's value - as it should be. But, if i click No, the message box appears again and i have to click No again. only after that it cancels the event and the cell returns to the initial value.

Any ideea how can i fix this ?

Thank you!

Parents Reply Children
No Data