gpt4 book ai didi

c# - TextBox GotFocus 事件没有响应

转载 作者:太空宇宙 更新时间:2023-11-03 14:13:14 24 4
gpt4 key购买 nike

非常简单:

private void textBox1_GotFocus(object sender, EventArgs e)
{
this.textBox1.Text = "AAA";
}

这似乎没有做任何事情。我的文本框称为文本框 1。没有错误,但它没有按照我的意愿行事。

有什么想法吗?

最佳答案

在你的表单构造函数中,确保你有这个:

this.textBox1.GotFocus += new EventHandler(textBox1_GotFocus);

GotFocus 事件对设计者是隐藏的,所以你必须自己做。

正如 Hans 指出的那样,GotFocus 基本上已被 Enter 事件取代,您应该改用它:

private void textBox1_Enter(object sender, EventArgs e)
{
this.textBox1.Text = "AAA";
}

关于c# - TextBox GotFocus 事件没有响应,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7154007/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com