1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
|
private void percentTextBox_TextChanged(object sender, EventArgs e)
{
try
{
// Convert the text to a Double and determine if it is a negative number.
if(double.Parse( percentTextBox.Text) < 0)
{
// If the number is negative, display it in Red.Alert !
percentTextBox.ForeColor = Color.Red;
}
else
{
// If the number is not negative, display it in Black.
percentTextBox.ForeColor = Color.Black;
// mis a jour Prix dans le 2eme TextBox
Price=Price*Double.Parse(percentTextBox.Text);
TextBoxPrice.Text =Price.ToString();
}
}
catch
{
// If there is an error, display the text using the system colors.
percentTextBox.ForeColor = SystemColors.ControlText;
}
} |
Partager