This article is a mirror article of machine translation, please click here to jump to the original article.

View: 15265|Reply: 1

[WinForm] .net/C# NumericUpDown control

[Copy link]
Posted on 1/12/2018 3:22:33 PM | | |

NumericUpDown, also known as the numeric selection control, is a control that displays and enters a value, the control provides a pair of up and down arrows, the user clicks on the up and down arrows to select a value, or directly enter a value
Control properties:
Maximum:设置数值允许的最大值,如果超过这个最大值会自动被修改为设置的最大值
Minimum:设置数值允许的最小值,如果超过这个最小值会自动被修改为设置的最小值
DecimalPlaces:获取或者设置数字显示框中的世十进制小数点的位数
Hexadecimal:获取或者设置一个值,该值指示显示框是否以十六进制的格式显示包含的值
InterceptArrowKeys:是否允许用户使用上下键调整值的大小
Value:获取显示框中的值
UpDownAlign:设置或获取数值显示框中向上和向下按钮的对齐方式

Create a new FormWin 32 program
Add the form code as follows
private void Form1_Load(object sender, EventArgs e)
{
     numericUpDown1.Minimum = 0;     Set the minimum allowed value
     numericUpDown1.Maximum = 100;   Set the maximum allowed value
     numericUpDown1.DecimalPlaces = 2;   Set the number of decimal places to 3 digits
     numericUpDown1.Increment = 1;       Set the step size to 1
     numericUpDown1.InterceptArrowKeys = true;    Allows adjusting values by up and down arrows
}

Also add a ValueChanged event for NumericUpDOwn
private void numericUpDown1_ValueChanged(object sender, EventArgs e)
       {
           textBox1.Text = "The value you entered is:" + numericUpDown1.Value;
       }




Previous:Windows 7 system + computer unique signature code
Next:.net/c# to set system time and JD time synchronization
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com