我爱Aspx >> Asp.Net >> 用Visual C#动态生成组件MessageBox.Show ( control.Text + "被按动了!" ) ;
}
}
当然如果你也可以单独为TextBox组件创建Click事件。此时创建的事件语句可改为:
myBox.Click += new System.EventHandler ( this.txt _Click ) ;
下面是实现txt _Click ( )事件的程序代码:
private void txt_Click ( object sender , System.EventArgs e )
{
TextBox currentButton = ( TextBox ) sender ;
MessageBox.Show ( currentButton.Text + "被按动了!");
下面是实现上面结果的程序源代码:
using System ;
using System.Drawing ;
using System.Collections ;
using System.ComponentModel ;
using System.Windows.Forms ;
using System.Data ;
namespace DynamicControls
{
public class Form1 : Form
{
private Button btnAdd ;
private System.ComponentModel.Container components = null ;
private Button txtAdd ;
//给产生的按钮定义一个数量计算器
private int counter ;
Ҷƪл˵?
C#书写规范[05-20]
用 C# 编写一个停放在任务栏上的..[05-20]
Visual C#.Net 网络程序开发-Soc..[05-20]
C#中一些字符串操作的常用用法[05-20]
使用 Visual C# .NET 向 Excel 工..[05-20]
在C#中改变系统时间 && ..[05-20]
在ASP.NET(C#)中使用Oralce Obje..[05-20]
ASP.NET c# 文件上传[05-20]
C#+ASP.NET开发基于Web的RSS阅读..[05-20]
ASP.net 验证码(C#)[05-20]
web组件的通信---浅谈事件[05-20]
WMI使用技巧集[05-20]
利用SQLDMO备份还原SQL SERVER[05-20]
WMI在网络编程中的应用[05-20]
ASP.NET远程建立IIS虚拟主机并指..[05-20]
Real Player ActiveX Control Li..[05-20]
使用JS创建虚拟目录,并引导进入浏..[05-20]
ASP.NET远程建立IIS虚拟主机并指..[05-20]
用ASP.NET对IIS中的虚拟目录进行..[05-20]
用ASP.NET对IIS中的虚拟目录进行..[05-20]