文档下载 文档下载导航
设为首页 | 加入收藏
搜索 请输入内容:  
 导航当前位置: 文档下载 > 所有分类 > IT/计算机 > 计算机软件及应用 > NumericUpDown代码
侵权投诉

NumericUpDown代码

下面的代码示例创建并初始化一个 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

第1页

你可能喜欢

热门文档

相关文档

  • NumericUpDown控件

    图2 NumericUpDown控件属性的使用程序主要代码如下: private void frmNumericUpDow_Load(object sender, EventArgs e) { this.numericUpDown1.Maximum = 20; this....

  • NumericUpDown 类

    示例下面的代码示例创建并初始化一个 NumericUpDown 控件,设置它的一些公共属性,并使用户可 以在运行时更改其中的某些属性。 此代码假定已经在窗体上放置三个 ...

  • NumericUpDown 控件(Windows 窗体)

    C# C++ VB NumericUpDown1.UpButton() 返回数值 ? 通过代码方式访问 Value 属性。 C# C++ VB If NumericUpDown1.Value >= 65 Then MessageBox.Show("Age ...

  • numericUpDown控件

    numericUpDown控件_IT/计算机_专业资料。c#中一些控件的用法bindingNavigator 中...c#winform sql 数据库的增删改查功能 最好把代码和数据库都给我 谢谢啦 急!...

  • 《更改文件名》软件源代码

    《更改文件名》软件源代码_计算机软件及应用_IT/计算机_专业资料。《更改文件...(numericUpDown3.Value.ToString()); n5++) { str += temp[n5].To...

  • 程序流控制(if,switch语句)

    Numericupdown Combo:item 定义下拉选项 Textbox Button 方法 1 (switch)的代码: string a; double c; decimal b; public Form6() { InitializeComponent(); ...

  • 第1章 数学计算应用程序设计

    1.5.3 【数学计算】应用程序的 功能实现与编码 1.编写程序代码本程序所实现的功能是计算销售收入。 其操作过程为:首先在NumericUpDown1 控件中输入商品的“销售...

  • C#汉诺塔演示和代码

    C#汉诺塔演示和代码_IT/计算机_专业资料。汉诺塔的演示界面: 本系统显示的...(); this.udLevels = new System.Windows.Forms.NumericUpDown(); this....

  • 3.程序流程控制

    掌握NumericUpDown控件的使用 掌握 控件的使用 掌握TextBox控件的使用 掌握 控件的使用 示例代码位于“ 示例\第 课 示例代码位于“CSharp示例 第3课\Savings” ...

  • 3.程序流程控制

    掌握NumericUpDown控件的使用 ? 掌握TextBox控件的使用 ? 示例代码位于“CSharp示例\第3课\Savings” 界面设计 nupdPrincipal, 输入本金 nupdRate, 输入年利率 ...

站点地图 | 文档上传 | 侵权投诉 | 手机版
本站所有资源均来自互联网,本站只负责收集和整理,均不承担任何法律责任,如有侵权等其它行为请联系我们.
文档下载 Copyright 2013 doc.guandang.net All Rights Reserved.  -  email