怎么给动态添加的textbox控件添加textchaged事件

shelless 2010-01-20 06:16:48
RT


最好给代码,不要链接。
...全文
125 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
shelless 2010-01-20
  • 打赏
  • 举报
回复
太粗细了,解决了。谢谢几位。
yooxee 2010-01-20
  • 打赏
  • 举报
回复
在VS中textbox.TextChanged += 后用2下TAB键,会自动出来,可以自己修改下托管函数的名称
HarveyYan 2010-01-20
  • 打赏
  • 举报
回复
private void attach_TextChanged(object sender, EventHandler e)


红字改为EventArgs
shelless 2010-01-20
  • 打赏
  • 举报
回复

private void toolStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e)//工具栏
{

if (e.ClickedItem.Text == "附件")
{
if (openFileDialog1.ShowDialog() ==DialogResult.OK)
{
attach.Name = "attachs";
attach.Width = 550;
attach.Height = 21;
attach.Location = new Point(72, 68);
splitContainer1.Panel1.Controls.Add(attach);
lbl.Name = "fujian";
lbl.Text = "附件:";
lbl.Location = new Point(21, 68);
splitContainer1.Panel1.Controls.Add(lbl);
toolStrip2.Location = new Point(13, 98);
splitContainer1.SplitterDistance = 135;
filename = openFileDialog1.FileNames;

foreach (string var in openFileDialog1.SafeFileNames)
{
attach.Text +=var+" ";
}
attach.TextChanged += new EventHandler(this.attach_TextChanged);
}
}

}
private void attach_TextChanged(object sender, EventHandler e)
{
if (attach.Text == "")
{
splitContainer1.Panel1.Controls.Remove(attach);
splitContainer1.Panel1.Controls.Remove(lbl);
toolStrip2.Location = new Point(13, 68);
splitContainer1.SplitterDistance = 105;
}
}


跟你的有区别吗?

错误 1 “attach_TextChanged”的重载均与委托“System.EventHandler”不匹配
memerycyb 2010-01-20
  • 打赏
  • 举报
回复

TextBox tb = new TextBox();
tb.TextChanged += new EventHandler(tb_TextChanged);

void tb_TextChanged(object sender, EventArgs e)
{
throw new Exception("The method or operation is not implemented.");
}

110,534

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧