Numericupdown控件是由system.windows.froms.Numericupdown类提供的,主要作用是一个数按一定的值进行增加或减少主要四个常用属性

 

Increment                每次单击按钮时增加或者减少的量

Maximum 最大值

Minimum 最小值

Value 当前值

decimalPlaces             显示小数的位数

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms; namespace Numericupdown
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
} private void Form1_Load(object sender, EventArgs e)
{
label3.Text = "设置值的增量";
button1.Text = "增加";
button2.Text = "减少";
label1.Text = "0";
numericUpDown1.Maximum = 10000;
} private void numericUpDown1_ValueChanged(object sender, EventArgs e)
{
label1.Text = numericUpDown1.Value.ToString();
} private void button1_Click(object sender, EventArgs e)
{
numericUpDown1.UpButton();
} private void button2_Click(object sender, EventArgs e)
{
numericUpDown1.DownButton();
} private void textBox2_TextChanged(object sender, EventArgs e)
{
try
{
numericUpDown1.Increment = int.Parse(textBox2.Text);
}
catch
{
MessageBox.Show("格式错误");
} } private void textBox1_TextChanged(object sender, EventArgs e)
{
try
{
numericUpDown1.DecimalPlaces = int.Parse(textBox1.Text);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message); } }
}
}

  

NUmericupdown控件的更多相关文章

  1. VB 中 NumericUpDown 控件 如何为手动输入设定触发事件

    Private Sub numDuration_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) ...

  2. C# System.Windows.Forms.NumericUpDown 控件全选其中文字

    num_length.Focus();                    UpDownBase updbText = (UpDownBase)num_length;                 ...

  3. C#常用控件介绍

                                                  目录 1.窗体(Form) 2.Label (标签)控件 3.TextBox(文本框)控件 4.RichTe ...

  4. .NET组件控件实例编程系列——5.DataGridView数值列和日期列

    在使用DataGridView编辑数据的时候,编辑的单元格一般会显示为文本框,逻辑值和图片会自动显示对应类型的列.当然我们自己可以手工选择列的类型,例如ComboBox列.Button列.Link列. ...

  5. winFrom 常用控件属性及方法介绍

    目录 1.窗体(Form) 2.Label (标签)控件 3.TextBox(文本框)控件 4.RichTextBox控件 5.NumericUpDown控件 6.Button(按钮)控件 7.Gro ...

  6. C#控件及常用设计整

    C#控件及常用设计整 1.窗体    1 2.Label 控件    3 3.TextBox 控件    4 4.RichTextBox控件    5 5.NumericUpDown 控件    7 ...

  7. Winform 控件

    ※控件在视图工具箱里面找,找到之后双击即可添加进来,也可以点住拖进来 ※每个工具,控件,窗体都有一个name,相当于id,用来标识该对象的名称,name值不允许重复 控件: 1.Label -- 文本 ...

  8. C#打印页面的纸张设置问题Spread表格控件

    这段时间学习spread控件,用到打印设置上边,其他的设置都还好说,但是打印纸张的大小,纸张类型等把我折腾的够呛,找了半天才找到,记录下来备查. 1.打印纸张类型: System.Drawing.Pr ...

  9. [WinForm] 使用反射将业务对象绑定到窗体或控件容器

    在WebForm中,可以使用反射将业务对象绑定到 ASP.NET 窗体控件.最近做Winform项目,也参考WebForm中的代码实现同样的功能.     Winform没有提供类似WebForm中的 ...

随机推荐

  1. MaxScript镜像函数

    看到有网友需要写的,其实镜像就是缩放改为负数 Fn MirrorObject argObjects argAxisName = ( local axisNames = #(#x,#y,#z) do ( ...

  2. API Test Postman接口测试之高级篇1

    API Test  Postman接口测试之高级篇1 一.postman中的请求参数简介: 1.请求参数简介: 点击params下面会出现key,value等信息,这里填写的会自动追加在url地址后面 ...

  3. MyBatis高级及其SSM框架搭建

    代码生成器 首先meaven项目中导入支持包 <dependencies> <!-- https://mvnrepository.com/artifact/mysql/mysql-c ...

  4. 获取BinaryReader中读取的文件名

    BinaryReader br; br = null; br = new BinaryReader(new FileStream("E:demo.txt", FileMode.Op ...

  5. LOJ#162. 快速幂 2(分块)

    题面 传送门 题解 orzljz 我们分块,设\(s=\sqrt{p}+1\),那么\(x^a\)可以拆成\((x^s)^{a/s}\)和\(x^{a\bmod s}\),\(O(s)\)预处理,\( ...

  6. time 模块学习

    前情提要: time模块是经常使用的模块.主要是用来记录时间,以及时间上的相关操作 一:时间戳 1:第一种形式 import time print(time.time()) 从1970 1 1 0:0 ...

  7. C语言数据结构之图的基本操作

    本博文是是博主在学习数据结构图的这一章知识时做的一些总结,代码运行环境:visual studio2017 纯C语言 ,当然掌握了方法,你也可以试着用其它的语言来实现同样的功能. 下面的程序主要实现了 ...

  8. kafka补充

     

  9. HTML01--基础概述

    HTML:Hyper Text Markup Language,超文本标记语言,不是编程语言,而是标记语言,使用一套标记标签来描述网页.通常来说,我们平时打开浏览器看到的网页由三部分组成,分别是HTM ...

  10. Unity3D碰撞触发函数

    首先要给被碰撞物体添加Box Collider,并在Is Trigger打勾 在被碰撞物体的脚本里,添加碰撞检测函数 void OnTriggerEnter(Collider other) { if ...