Exemple #1
0
        private void ShowEditForm(NumberForm numberForm, Action method)
        {
            numberForm.Closing += (_, args) =>
            {
                if (numberForm.DialogResult != DialogResult.OK)
                {
                    return;
                }

                try
                {
                    method();
                    CommitChanges();
                }
                catch (Exception e)
                {
                    MessageBox.Show(String.Format("Error {0}", e.GetType()), "Error",
                        MessageBoxButtons.OK, MessageBoxIcon.Hand,
                        MessageBoxDefaultButton.Button1);
                    args.Cancel = true;
                }
            };

            numberForm.ShowDialog();
        }