/*private void ValidDouble_Validating(object sender, System.ComponentModel.CancelEventArgs e) { * string myMessage=""; * try{ * if(Text==""){ * errorProvider1.SetError(this,""); * return;//Text="0"; * } * if(System.Convert.ToDouble(this.Text)>MaxVal) * throw new Exception("Number must be less than "+(MaxVal+1).ToString()); * if(System.Convert.ToDouble(this.Text)<MinVal) * throw new Exception("Number must be greater than or equal to "+(MinVal).ToString()); * errorProvider1.SetError(this,""); * } * catch(Exception ex){ * if(ex.Message=="Input string was not in a correct format."){ * myMessage="Must be a number. No letters or symbols allowed"; * } * else{ * myMessage=ex.Message; * } * errorProvider1.SetError(this,myMessage); * } * }*/ private void ValidDouble_TextChanged(object sender, EventArgs e) { string myMessage = ""; try { if (Text == "") { errorProvider1.SetError(this, ""); return; //Text="0"; } if (System.Convert.ToDouble(this.Text) > MaxVal) { throw new Exception("Number must be less than or equal to " + MaxVal.ToString()); } if (System.Convert.ToDouble(this.Text) < MinVal) { throw new Exception("Number must be greater than or equal to " + (MinVal).ToString()); } errorProvider1.SetError(this, ""); } catch (Exception ex) { if (ex.Message == "Input string was not in a correct format.") { myMessage = "Must be a number. No letters or symbols allowed"; } else { myMessage = ex.Message; } errorProvider1.SetError(this, myMessage); } }
/// <summary> /// Sets the maximum. /// </summary> /// <param name="value">The value.</param> /// <returns></returns> public double SetMax(string value) { MaxVal.Text = value; MaxVal.UpdateLayout(); return(MaxVal.ActualWidth); }