|
C# Winform 开发框架集成快捷键功能 (Hotkey)
C# Winform 开发框架集成快捷键功能 (Hotkey)
开发框架内是使用KeyDown事件集成快捷键功能的,代码如下: frmBase: C# Code:
//处理用户按键事件 private void frmBase_KeyDown(object sender, KeyEventArgs e) { if (e.Alt && (e.KeyCode >= Keys.A) && (e.KeyCode < Keys.Z)) { this.DoExecuteHotKey(e); return; } } protected virtual void DoExecuteHotKey(KeyEventArgs e) { //虚拟方法,由派生窗体处理自己的热键。 }
C# Code:
protected override void DoExecuteHotKey(KeyEventArgs e) { if (e.Alt) { if (e.KeyCode == Keys.H) this.DoHelp(null); //Ctrl+H:帮助 else if (e.KeyCode == Keys.X) this.DoClose(null);//Ctrl+X:关闭 else base.DoExecuteHotKey(e); } }
C# Code:
protected override void DoExecuteHotKey(KeyEventArgs e) { if (e.Alt) { if (e.KeyCode == Keys.V) this.DoViewContent(_buttons.GetButtonByName("btnView"));//查看 else if (e.KeyCode == Keys.N) this.DoAdd(_buttons.GetButtonByName("btnAdd"));//新增 else if (e.KeyCode == Keys.D) this.DoDelete(_buttons.GetButtonByName("btnDelete"));//删除 else if (e.KeyCode == Keys.E) this.DoEdit(_buttons.GetButtonByName("btnEdit"));//修改 else if (e.KeyCode == Keys.P) this.DoPrint(_buttons.GetButtonByName("btnPrint"));//打印 else if (e.KeyCode == Keys.S) this.DoSave(_buttons.GetButtonByName("btnSave"));//保存 else if (e.KeyCode == Keys.C) this.DoCancel(_buttons.GetButtonByName("btnCancel"));//取消 else base.DoExecuteHotKey(e);//由基类处理 } } //来源:C/S框架网(www.csframework.com) QQ:1980854898
参考文档:
C/S框架网专注C# Winform 开发框架研发十年 C# Winform 开发框架 - 业务单据附件管理解决方案(原) C# Winform 开发平台新功能 - C/S系统开发框架旗舰版V5.0 C# Winform增删查改快速开发框架|C/S框架网 基于C# Winform三层框架打造的C/S系统开发平台成功案例(2008-2018年) Winform 开发框架 Winform 开发平台 C# Winform开发框架及C# Winform开发平台 C# Winform 进销存系统C/S架构开发框架已经形成 C# Winform CS结构快速开发框架高级版V3.0 - 视频介绍
其它资料:
什么是C/S结构? | C/S框架核心组成部分 | C/S框架-WebService部署图 | C/S框架-权限管理 | C/S结构系统框架 - 3.0高级版介绍 | C/S结构系统框架 - 功能介绍 | C/S结构系统框架 - 产品列表 | C/S结构系统框架 - 应用展示(图) | |
|