C#Winfrom中,窗体加载时会自动执行一次控件的textchange事件,怎么让它不执行?

http://zhidao.baidu.com/link?url=iTSyfa5_RJBSb37S8efdWoL5eDMrnxeAm-prhGSNBXqdP9r7PzNDQTc7gVzJgCNdzliVAqbr9M3ChiZUDmT98_

你应该是在加载窗体时为文本框赋值了。
你可以:
1.把绑定事件的代码放到赋值之后
public Form1()
{
InitializeComponent();

textBox1.Text = "123";
this.textBox1.TextChanged += new System.EventHandler(this.textBox1_TextChanged);//同时去掉InitializeComponent中的绑定代码
}
2.添加一个标记标量用于标识是不是正在加载数据:
private bool m_IsLoading = false;
public Form1()
{
InitializeComponent();

m_IsLoading = true;
textBox1.Text = "123";
m_IsLoading = false;

}

private void textBox1_TextChanged(object sender, EventArgs e)
{
if (!m_IsLoading)
{
MessageBox.Show("123");
}
}
原文地址:https://www.cnblogs.com/carl2380/p/3862885.html