Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to use EXIT button without interference from LEAVE e
Message
General information
Forum:
ASP.NET
Category:
Other
Environment versions
Environment:
C# 1.1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Miscellaneous
Thread ID:
01053590
Message ID:
01054188
Views:
16
Bonnie,

Here's what I ended up doing. I removed my code fromt he Leave Event and palced it into the Validating event; there was one last thing I had to do, in order to be able to exit without seeing the numeric erro messagebox appear each time I exited and that is: I added "e.Cancel=false;" to the Validating Event at the beginning of the code. The validating still works and I am now able to exit without any error messages.
        private void exitButton_Click(object sender, EventArgs e)
        {
            //this.Close();
            Application.Exit();
        }
        private void basePriceTextBox_Leave(object sender, EventArgs e)
        {
            
        }

        private void basePriceTextBox_Validating(object sender, CancelEventArgs e)
        {
            e.Cancel = false;
            string strMessageForBasePrice = "";
            try
            {
                if (decimal.Parse(this.basePriceTextBox.Text) >= 1)
                {
                    enableControls();
                    this.tradeInAllowanceTextBox.Focus();
                }
                if (decimal.Parse(this.basePriceTextBox.Text) < 1)
                {
                    disableControls();
                }
            }
            catch (FormatException err)
            {
                strMessageForBasePrice =
                    "Non-numeric value was entered for Base Price";
                MessageBox.Show(strMessageForBasePrice + ". " + err.Message,
                    "Data Entry Error",
                    MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Previous
Reply
Map
View

Click here to load this message in the networking platform