Very simple:
private void textBo开发者_开发技巧x1_GotFocus(object sender, EventArgs e)
{
this.textBox1.Text = "AAA";
}
This does not appear to be doing anything. my textBox is called textBox1. No error, but it is not doing what I want.
Any idea?
In your form's constructor, make sure you have this:
this.textBox1.GotFocus += new EventHandler(textBox1_GotFocus);
The GotFocus event is hidden from the designer, so you have to do it yourself.
As Hans pointed out, GotFocus is basically replaced by the Enter event, and you should use that instead:
private void textBox1_Enter(object sender, EventArgs e)
{
this.textBox1.Text = "AAA";
}
精彩评论