如何按ESC关闭窗口?

在InitializeComponent();下面增加KeyDown事件,如:

     public ModifyPrice()
        {
            InitializeComponent();
            this.KeyDown += ModifyPrice_KeyDown;
        }

        private void ModifyPrice_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Escape)//Esc键  
            {
                this.Close();
            }
        }

 

相关文章:

  • 2021-05-30
  • 2022-12-23
  • 2022-12-23
  • 2021-09-16
  • 2022-12-23
  • 2022-12-23
  • 2021-11-07
猜你喜欢
  • 2022-02-08
  • 2022-12-23
  • 2021-10-20
  • 2021-07-17
  • 2022-12-23
  • 2021-07-15
  • 2021-06-06
相关资源
相似解决方案