How to display an empty value in NumericUpDown control?

流过昼夜 提交于 2019-11-29 20:47:53

问题


I have a Windows Forms application that includes NumericUpDown control With Minimum and Maximum values set to (50:80) accordingly and step 1.

When form loads the NumericUpDown shows 50.

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?


回答1:


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

With that NumericUpDown1 will look empty, but NumericUpDown1.Value is still 50.



来源:https://stackoverflow.com/questions/20707734/how-to-display-an-empty-value-in-numericupdown-control

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!