用户控件怎样公开标准控件中的事件 [Category("自定义")]
public event EventHandler TextChange; private void comboBox1_TextChanged(object sender, EventArgs e)
{
if (TextChange != null)
{
TextChange(this, new EventArgs());
}
}
客户程序执行时根本就不触发这个事件,到是怎么回事?????????
public event EventHandler TextChange; private void comboBox1_TextChanged(object sender, EventArgs e)
{
if (TextChange != null)
{
TextChange(this, new EventArgs());
}
}
客户程序执行时根本就不触发这个事件,到是怎么回事?????????
你的用户控件中有comboBox1.TextChanged+=new EventHandler(this.comboBox1_TextChanged);
这句吗?
问题是解决了,但是还是不是很明白其中的意思,你能不能解释一下,谢了
comboBox1.TextChanged+=new EventHandler(this.comboBox1_TextChanged);
这句才是订阅这个事件光触发没订阅怎么会发生??就像有人卖菜没人买菜怎么会卖出去??
~~~~~
动态加载用户控件后,使用用户控件怎么象使用窗体:if (cm.ShowDialog() != DialogResult.OK) 的使用呢?
cm是窗体的对象!