All articles| All Pictures| All Softwares| All Video| Go home page| Write articles| Upload pictures

Reading number is top 10 articles
C#教程:C#中的赋值运算符
PHP+MySQL分页显示示例分析_php资料_编程技术
在delphi中面向对象的特性
ASP.NET2.0中实现图像转换过滤效果_.net资料_编程技术
Web页面的数据导出excel时的格式问题_[Asp.Net教程]
PHP的十个高级技巧(上)_[PHP教程]
如何在IE右键菜单中添加菜单项以及如何添加IE任务栏按钮_.net资料_编程技术
ASP.NET写文件
C#中 DirectoryEntry组件应用实例
.NET,命名规范(控件、数据类型等)_[Asp.Net教程]
Reading number is top 10 pictures
修电脑也有这么漂亮的美女
29 the belle stars after bath figure1
The real super beauty10
YangYuYing and ZhengShaoQiu dance on the generous come interest dye-in-the-wood
福利是必须的
The money of more than 100 countries and regions10
Plump, too plump!2
The Soviet union swimsuit exposure in the 70 year3
yy365网站上的美女2
一万二一支的万珂,用得真心肉疼。
Download software ranking
Twenty piece of palm leaf
apache-tomcat-6.0.33
VeryCD电驴(EasyMule) V1.1.9 Build09081
Boxer Classic video2
Professional killers2 for Android
Popkart Cracked versions Mobile phone games
C#编程思想
The king of fighters 97(Mobile phone games-apk)
Boxer's Top ten classic battle9
Professional killers2 data package
qq published in(发表于) 2014/7/11 9:17:38 Edit(编辑)
C#中NumericUpDown 控件应用实例

C#中NumericUpDown 控件应用实例

C#中NumericUpDown 控件应用实例

NumericUpDown 控件

1.功能

NumericUpDown控件看起来像是一个文本框与一对箭头的组合,用户可以单击箭头来调整数值。NumericUpDown控件显示并设置选择列表中的单个数值,用户可以通过单击向上和向下按钮、按向上键和向下键或键入一个数字来增大和减小数字。单击向上键时,值沿最大值方向增加;单击向下键时,值沿最小值方向减少。图1所示为NumericUpDown控件。



图1 NumericUpDown控件

2.属性

NumericUpDown控件常用属性及说明如表1所示。



表1 NumericUpDown控件常用属性及说明

下面对比较重要的属性进行详细介绍。

(1)Maximum属性。

语法:

public decimal Maximum { get; set; }

属性值:数字显示框的最大值。默认值为100。

(2)Minimum属性。

语法:

public decimal Minimum { get; set; }

属性值:数字显示框的最小允许值。默认值为0。

(3)Value属性。

语法:

public decimal Value { get; set; }

属性值:NumericUpDown控件的数值。

(4)Increment属性。

语法:

public decimal Increment { get; set; }

属性值:单击数字显示框上的向上或向下按钮时,Value属性要递增或递减的值。默认值为1。

示例

NumericUpDown控件属性的使用

本示例主要介绍如何在Windows窗体中设置NumericUpDown控件的属性,运行结果如图2所示。



图2 NumericUpDown控件属性的使用

程序主要代码如下:

private void frmNumericUpDow_Load(object sender, EventArgs e)

{

this.numericUpDown1.Maximum = 20;

this.numericUpDown1.Minimum = 1;

this.numericUpDown1.Increment = 2;

this.numericUpDown1.Value = 4;

}

完整程序代码如下:

★★★★★主程序文件完整程序代码★★★★★

using System;

using System.Collections.Generic;

using System.Windows.Forms;

namespace _8_09

{

static class Program

{

///



/// 应用程序的主入口点。

///


[STAThread]

static void Main()

{

Application.EnableVisualStyles();

Application.SetCompatibleTextRenderingDefault(false);

Application.Run(new frmNumericUpDow());

}

}

}

★★★★★frmNumericUpDow窗体设计文件完整程序代码★★★★★

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Text;

using System.Windows.Forms;

namespace _8_09

{

public partial class frmNumericUpDow : Form

{

public frmNumericUpDow()

{

InitializeComponent();

}

private void frmNumericUpDow_Load(object sender, EventArgs e)

{

this.numericUpDown1.Maximum = 20;

this.numericUpDown1.Minimum = 1;

this.numericUpDown1.Increment = 2;

this.numericUpDown1.Value = 4;

}

private void button1_Click(object sender, EventArgs e)

{

}

private void button2_Click(object sender, EventArgs e)

{

}

private void numericUpDown1_ValueChanged(object sender, EventArgs e)

{

}

}

}

★★★★★frmNumericUpDow窗体代码文件完整程序代码★★★★★

namespace _8_09

{

partial class frmNumericUpDow

{

///

/// 必需的设计器变量。

///


private System.ComponentModel.IContainer components = null;

///

/// 清理所有正在使用的资源。

///


/// 如果应释放托管资源,为 true;否则为 false。

protected override void Dispose(bool disposing)

{

if (disposing && (components != null))

{

components.Dispose();

}

base.Dispose(disposing);

}

#region Windows 窗体设计器生成的代码

///

/// 设计器支持所需的方法 - 不要

/// 使用代码编辑器修改此方法的内容。


添加到del.icio.us 添加到新浪ViVi 添加到百度搜藏 添加到POCO网摘 添加到天天网摘365Key 添加到和讯网摘 添加到天极网摘 添加到黑米书签 添加到QQ书签 添加到雅虎收藏 添加到奇客发现 diigo it 添加到饭否 添加到飞豆订阅 添加到抓虾收藏 添加到鲜果订阅 digg it 貼到funP 添加到有道阅读 Live Favorites 添加到Newsvine 打印本页 用Email发送本页 在Facebook上分享


Disclaimer Privacy Policy About us Site Map

If you have any requirements, please contact webmaster。(如果有什么要求,请联系站长)
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.