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

Reading number is top 10 articles
DataList中HyperLink数据绑定及链接写法_[Asp.Net教程]
在ASP.NET页中检测浏览器类型_.net资料_编程技术
php下免费的加速器,PHP Accelerator_[PHP教程]
HTML 初学者指南_[Html教程]
VB.NET实现窗体图标最小化到状态栏_.net资料_编程技术
left join的总结_[SQL Server教程]
delphi文本文件类型的使用方法详解
通过SQLSERVER重启SQLSERVER服务和计算机_[SQL,Server教程]
第四篇:使用Visual,Studio,2008实现用户注册页面_[Asp.Net教程]
SQL数据操作基础(中级)7_mssql学习_编程技术
Reading number is top 10 pictures
徐若瑄展示美丽胸围3
大人物的礼物
寒流来了
XuYing poker perspective garment debut
The real super beauty14
Go to the national museum1
Female model behind the bitterness, often being overcharged4
七步解决性冷淡
乳娘帕梅拉安德森2
移民小国也实惠1
Download software ranking
apache-tomcat-6.0.33
WebService在.NET中的实战应用教学视频 → 第4集
Boxer's Top ten classic battle4
虚拟机汉化软件
星际争霸1.08硬盘免安装版
Professional killers2 data package
尖东毒玫瑰A
Sora aoi, the maid, students' uniforms
Macromedia Dreamweaver 8
终极变速大师Speeder3.26
qq published in(发表于) 2014/7/11 9:19:14 Edit(编辑)
C#中动作类型控件应用实例

C#中动作类型控件应用实例

C#中动作类型控件应用实例

动作类型控件

使用动作类控件,用户可以与应用程序进行交互,这些控件可以帮助用户在应用程序中执行特定任务。动作类控件包括Button、ToolStrip、MenuStrip和ConText MenuStrip控件等。

1.Button控件功能

Button控件允许用户通过单击来执行各种操作。当Button控件被单击时,它看起来像是被按下,然后被释放。当用户单击Button控件时,即调用其Click事件执行各种操作。图1所示为Button控件。



图1 Button控件

2.Button控件属性

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



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

3.Button控件方法

PerformClick方法:该方法引发Button控件的Click事件。当需要在用户没有单击按钮时也执行Click事件中代码时,可以使用此方法。

4.Button控件事件

Click事件:该事件主要用于Button控件的默认事件和主要事件,单击按钮时触发该事件。

示例

Click事件的使用

本示例中,当程序运行时,单击【清空】按钮,清空文本框中内容。示例运行结果如图2所示。



图2 Click事件

程序主要代码如下:

单击【清空】按钮,清空文本框中内容。【清空】按钮的Click事件代码如下:

private void button1_Click(object sender, EventArgs e)

{

this.textBox1.Clear();

this.textBox2.Clear();

}

完整程序代码如下:

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

using System;

using System.Collections.Generic;

using System.Windows.Forms;

namespace _8_03

{

static class Program

{

///



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

///


[STAThread]

static void Main()

{

Application.EnableVisualStyles();

Application.SetCompatibleTextRenderingDefault(false);

Application.Run(new frmText());

}

}

}

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

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Text;

using System.Windows.Forms;

namespace _8_03

{

public partial class Form1 : Form

{

public Form1()

{

InitializeComponent();

}

}

}
★★★★★Form1窗体代码文件完整程序代码★★★★★

namespace _8_03

{

partial class Form1

{

///

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

///


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 窗体设计器生成的代码

///

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

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

///


private void InitializeComponent()

{

this.components = new System.ComponentModel.Container();

this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;

this.Text = "Form1";

}

#endregion

}

}

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


添加到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.