C#控件怎样获取,和失去焦点的处理

  • publicForm1()
  • {
  • InitializeComponent();
  • textBox1.Enter+=newEventHandler(textBox1_Enter);//获得焦点事件
  • textBox1.Leave+=newEventHandler(textBox1_Leave);//失去焦点事件。
  • }
  •  
  • void textBox1_Enter(object sender,EventArgs e)
  • {
  • MessageBox.Show("获得了焦点");
  • }
  •  
  • void textBox1_Leave(object sender,EventArgs e)
  • {
  • MessageBox.Show("失去了焦点");
  • }


                            

你可能感兴趣的:(C#)