下面的代码示例创建并初始化一个 NumericUpDown 控件,设置它的一些公共属性,并使用户可以在运行时更改其中的某些属性。 此代码假定已经在窗体上放置三个 CheckBox 控件,并且已经实例化它们的 Click 事件的处理程序。DecimalPlaces 、ThousandsSeparator 和 Hexadecimal 属性在每个复选框的 Click 事件上设置。
Public Sub InstantiateMyNumericUpDown()
' Create and initialize a NumericUpDown control.
numericUpDown1 = New NumericUpDown()
' Dock the control to the top of the form.
numericUpDown1.Dock = System.Windows.Forms.DockStyle.Top
' Set the Minimum, Maximum, and initial Value.
numericUpDown1.Value = 5
numericUpDown1.Maximum = 2500
numericUpDown1.Minimum = - 100
' Add the NumericUpDown to the Form.
Controls.Add(numericUpDown1)
End Sub
' Check box to toggle decimal places to be displayed.
Private Sub checkBox1_Click(sender As Object, e As EventArgs)
' If DecimalPlaces is greater than 0, set them to 0 and round the ' current Value; otherwise, set DecimalPlaces to 2 and change the ' Increment to 0.25.
If numericUpDown1.DecimalPlaces > 0 Then
numericUpDown1.DecimalPlaces = 0
numericUpDown1.Value = Decimal.Round(numericUpDown1.Value, 0) Else
numericUpDown1.DecimalPlaces = 2
numericUpDown1.Increment = 0.25D
End If
End Sub
' Check box to toggle thousands separators to be displayed.
Private Sub checkBox2_Click(sender As Object, e As EventArgs)
' If ThousandsSeparator is true, set it to false;
' otherwise, set it to true.
If numericUpDown1.ThousandsSeparator Then
numericUpDown1.ThousandsSeparator = False
Else
numericUpDown1.ThousandsSeparator = True
End If
End Sub
图2 NumericUpDown控件属性的使用程序主要代码如下: private void frmNumericUpDow_Load(object sender, EventArgs e) { this.numericUpDown1.Maximum = 20; this....
示例下面的代码示例创建并初始化一个 NumericUpDown 控件,设置它的一些公共属性,并使用户可 以在运行时更改其中的某些属性。 此代码假定已经在窗体上放置三个 ...
C# C++ VB NumericUpDown1.UpButton() 返回数值 ? 通过代码方式访问 Value 属性。 C# C++ VB If NumericUpDown1.Value >= 65 Then MessageBox.Show("Age ...
numericUpDown控件_IT/计算机_专业资料。c#中一些控件的用法bindingNavigator 中...c#winform sql 数据库的增删改查功能 最好把代码和数据库都给我 谢谢啦 急!...
《更改文件名》软件源代码_计算机软件及应用_IT/计算机_专业资料。《更改文件...(numericUpDown3.Value.ToString()); n5++) { str += temp[n5].To...
Numericupdown Combo:item 定义下拉选项 Textbox Button 方法 1 (switch)的代码: string a; double c; decimal b; public Form6() { InitializeComponent(); ...
1.5.3 【数学计算】应用程序的 功能实现与编码 1.编写程序代码本程序所实现的功能是计算销售收入。 其操作过程为:首先在NumericUpDown1 控件中输入商品的“销售...
C#汉诺塔演示和代码_IT/计算机_专业资料。汉诺塔的演示界面: 本系统显示的...(); this.udLevels = new System.Windows.Forms.NumericUpDown(); this....
掌握NumericUpDown控件的使用 掌握 控件的使用 掌握TextBox控件的使用 掌握 控件的使用 示例代码位于“ 示例\第 课 示例代码位于“CSharp示例 第3课\Savings” ...
掌握NumericUpDown控件的使用 ? 掌握TextBox控件的使用 ? 示例代码位于“CSharp示例\第3课\Savings” 界面设计 nupdPrincipal, 输入本金 nupdRate, 输入年利率 ...
热门文档