Hi I have a numericupdown box and I am trying to load the value of it each time the form loads.
I have tried the following with no joy
string striko1value = clsData.GetStriko1GasReading();
decimal striko1 = decimal.Parse(striko1value);
Striko1Numeric.Value = Convert.ToDecimal(striko1);
I have also tried this
Striko1Numeric.Value = (striko1);
Anyone have any ideas about how I would do this or where I could read up on this.
Supposing that your clsData.GetStriko1GasReading()
effectively returns a string that can be interpreted as a decimal value, then you probably have a value that is outside the Minimum or Maximum value allowed to the NumericUpdown control
string striko1value = clsData.GetStriko1GasReading();
decimal striko1;
if(decimal.TryParse(striko1value, out striko1))
{
if(striko1 > Striko1Numeric.Maximum || striko1 < Striko1Numeric.Minimum)
MessageBox.Show("Value not allowed");
else
Striko1Numeric.Value = striko1;
}
else
MessageBox.Show("Not a valid decimal number");
got it guys the Maximum value that i allowed was less than the value that was at striko1.
Thaks for the help
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.