不太清楚你的要求,是不是像这样的呢:
Button but=new Button()
but.Click+=new System.EventHandler(this.btn_Click);
你还是想用动态的调用控件,在动态控件上加载啊,如果是这样,你可能要强制转换一下了.
Button but=new Button()
but.Click+=new System.EventHandler(this.btn_Click);
你还是想用动态的调用控件,在动态控件上加载啊,如果是这样,你可能要强制转换一下了.
解决方案 »
- 弱弱的一个AJAX的问题!~~~
- 这种按钮如何实现?
- 在线等……我用datagrid 绑定后显示分页,但是我想在页码1,2,3……前面加上“page” 这个单词 要怎么加上???
- 求如何取cookie
- C#:谁有"可伸缩个性化窗体"的源代码,即刻给分
- 100分求:为什么使用Sockte接受传送的中文字符串是乱码????
- 一个decimal类型的数222.00的正则表达式
- 请教,,帮我看一下代码..语法错了.帮忙改一下
- winform用串口对MC52i的操作连接成功之后为什么打开连接通道总是返回错误
- 请问,winform下,datagrid中,升序排序时,想把空的行放在后面,可以怎么作?
- 如何对TreeView进行数据绑定?
- 新加记录时,如何实现dataGrid的同步更新?高手指教!
{
string astel;
astel=e.evt[1];//在调试的时候可以看到e.evt[1];//,但这里这样用不行,说无法将带 [] 的索引应用于“object”类型的表达式
this.label1.Text=astel; }
=========================
用户控件代码:
using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Windows.Forms;namespace ZZTestForm
{
public delegate void TextBoxChangedHandle(string message);
/// <summary>
/// UserControl1 的摘要说明。
/// </summary>
public class UserControl1 : System.Windows.Forms.UserControl
{
public event TextBoxChangedHandle TextBoxChanged;
private System.Windows.Forms.TextBox textBox1;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null; public UserControl1()
{
InitializeComponent();
}
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
} #region 组件设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器
/// 修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.textBox1 = new System.Windows.Forms.TextBox();
this.SuspendLayout();
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(20, 32);
this.textBox1.Name = "textBox1";
this.textBox1.TabIndex = 0;
this.textBox1.Text = "textBox1";
this.textBox1.TextChanged += new System.EventHandler(this.textBox1_TextChanged);
//
// UserControl1
//
this.Controls.Add(this.textBox1);
this.Name = "UserControl1";
this.Size = new System.Drawing.Size(150, 96);
this.ResumeLayout(false); }
#endregion private void textBox1_TextChanged(object sender, System.EventArgs e)
{
TextBoxChanged(this.textBox1.Text);
}
}
}
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;namespace ZZTestForm
{
/// <summary>
/// Form1 的摘要说明。
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private ZZTestForm.UserControl1 userControl11;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null; public Form1()
{
InitializeComponent();
} /// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
} #region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.userControl11 = new ZZTestForm.UserControl1();
this.SuspendLayout();
//
// userControl11
//
this.userControl11.Location = new System.Drawing.Point(96, 48);
this.userControl11.Name = "userControl11";
this.userControl11.Size = new System.Drawing.Size(150, 96);
this.userControl11.TabIndex = 0;
this.userControl11.TextBoxChanged += new ZZTestForm.TextBoxChangedHandle(this.userControl11_TextBoxChanged);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(332, 217);
this.Controls.Add(this.userControl11);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false); }
#endregion /// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
} private void userControl11_TextBoxChanged(string message)
{
MessageBox.Show("你改变了用户控件中TextBox的值:"+message);
} }
}