码迷,mamicode.com
首页 > 其他好文 > 详细

NUmericupdown控件

时间:2018-03-22 17:35:14      阅读:159      评论:0      收藏:0      [点我收藏+]

标签:rgs   http   最小值   错误   mil   partial   max   change   csharp   

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控件

标签:rgs   http   最小值   错误   mil   partial   max   change   csharp   

原文地址:https://www.cnblogs.com/xiaowie/p/8624291.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!