C# 我可以使 NumericUpDown 控件的最大值不受限制,而不是在其 Maximum 属性中指定一个值吗?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/824664/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Can I make the maximum value of a NumericUpDown control unlimited instead of specifying a value in its Maximum property?
提问by
As the title says, is there a way to make the maximum value of a NumericUpDown control unlimited instead of having to specify a specific value its the Maximum property?
正如标题所说,有没有办法使 NumericUpDown 控件的最大值不受限制,而不必为其 Maximum 属性指定一个特定值?
采纳答案by stevehipwell
Set the NumericUpDown Maximum property to the MaxValue property of the data type it is representing.
将 NumericUpDown Maximum 属性设置为它所表示的数据类型的 MaxValue 属性。
回答by Patrick McDonald
NumericUpDown1.Maximum = Decimal.MaxValue;
回答by TheTXI
You cannot set the property to unlimited or infinity or anything like that, but you can use the MaxValue of the data type you are using (Integer.MaxValue, Decimal.MaxValue, etc.) which will give you as far a range as possible without incurring overflow errors.
您不能将属性设置为无限制或无穷大或类似的东西,但您可以使用您正在使用的数据类型的 MaxValue(Integer.MaxValue、Decimal.MaxValue 等),这将为您提供尽可能远的范围,而无需导致溢出错误。