如何在NumericUpDown控件中显示一个空值? [英] How to display an empty value in NumericUpDown control?
问题描述
我有一个Windows Forms应用程序,该应用程序包含NumericUpDown
控件,并且Minimum
和Maximum
值分别设置为(50:80)和步骤1.
I have a Windows Forms application that includes NumericUpDown
control With Minimum
and Maximum
values set to (50:80) accordingly and step 1.
加载表单时,NumericUpDown
显示50.
When form loads the NumericUpDown
shows 50.
我知道NumericUpDown
用于选择数字和数字类型,并且始终具有值,但是有什么方法可以使它在表单加载时显示为空?
I know that NumericUpDown
is for picking numbers and numeric types and always has a value, but is there any way to make it show empty when form loads?
推荐答案
您不能将默认的NumericUpDown控件设置为空. NumericUpDown需要一个值来增加/减少.如果空"只是用户最初看到表单时看起来是空的问题,则可以通过将NumericUpDown的文本"设置为空来对其进行破解:
You can't make default NumericUpDown control empty. NumericUpDown need a value to increase/decrease from. If 'empty' is only a matter of look empty when user see the form at first, then you can hack it by setting NumericUpDown's Text to empty:
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
NumericUpDown1.Text = ""
End Sub
NummericUpDown1会显示为空,但NumericUpDown1.Value仍为50.
With that NumericUpDown1 will look empty, but NumericUpDown1.Value is still 50.
这篇关于如何在NumericUpDown控件中显示一个空值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!