您的位置:首页 > 编程语言 > C#

【C#】C#winform 双击/按"F12"键全屏,按"Esc"键退出

2016-12-19 10:43 357 查看
private void Lottery_DBClick(object sender, EventArgs e)

{

this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;// 设置边框为 None

this.WindowState = FormWindowState.Maximized;// 最大化

this.TopMost = true;// 置顶

this.KeyPreview = true;// 允许窗体先收到键盘事件

this.KeyUp += new KeyEventHandler(Lottery_KeyUp);// 允许窗体先收到键盘事件

this.Show();//显示 Form

}

private void Lottery_KeyUp(object sender, KeyEventArgs e)

{

if (e.KeyCode == Keys.Escape)//"Esc"按键退出全屏

{

this.WindowState = FormWindowState.Normal;

this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Sizable;

}

if (e.KeyCode == Keys.F12)

{

this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;// 设置边框为 None

this.WindowState = FormWindowState.Maximized;// 最大化

this.TopMost = true;// 置顶

this.KeyPreview = true;// 允许窗体先收到键盘事件

this.KeyUp += new KeyEventHandler(Lottery_KeyUp);// 允许窗体先收到键盘事件

this.Show();//显示 Form

}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: