日期:2014-05-16  浏览次数:21070 次

C# 怎么退出全屏模式
我在Load时写了这3行代码
this.TopMost = true;
            this.FormBorderStyle = FormBorderStyle.None;
            this.WindowState = FormWindowState.Maximized;

现在想通过按键盘上的ESC退出全屏,添加了
private void Form1_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyValue == 27)
            {
                this.WindowState = FormWindowState.Normal;
            }
        }

        private void Form1_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == (char)27)
            {
                this.WindowState = FormWindowState.Normal;
            }
        }

调试的时候竟然都没有进我断点程序,请问这是怎么回事啊?
------解决方案--------------------
this.KeyPreview=true;
  
*****************************************************************************
签名档: http://feiyun0112.cnblogs.com/
------解决方案--------------------
this.KeyPreview=true;
启用键盘事件