在vs里面选择TextBox在事件栏里面是找不到LostFocus事件的,但是在代码里面可以找到
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Test210825
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
textBox1.LostFocus += TextBox1_LostFocus;
}
int i = 0;
private void TextBox1_LostFocus(object sender, EventArgs e)
{
i++;
textBox2.Text = i.ToString();
}
private void textBox1_KeyUp(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
TextBox1_LostFocus(sender, e);
}
}
}
}