[英]NumericUpDown how to setvalue
Hi I have a numericupdown box and I am trying to load the value of it each time the form loads. 嗨,我有一个numericupdown框,每次加载表单时,我都试图加载它的值。
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 假设您的clsData.GetStriko1GasReading()
有效地返回了一个可以解释为十进制值的字符串,那么您的值可能超出了NumericUpdown控件允许的最小值或最大值
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. 得到了我允许的最大值小于striko1的值。
Thaks for the help 感谢帮助
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.