惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

C
CXSECURITY Database RSS Feed - CXSecurity.com
WordPress大学
WordPress大学
Microsoft Security Blog
Microsoft Security Blog
GbyAI
GbyAI
V
Visual Studio Blog
The Register - Security
The Register - Security
Y
Y Combinator Blog
I
InfoQ
小众软件
小众软件
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Scott Helme
Scott Helme
C
Cybersecurity and Infrastructure Security Agency CISA
T
Threatpost
Hacker News: Ask HN
Hacker News: Ask HN
P
Privacy International News Feed
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
A
Arctic Wolf
P
Privacy & Cybersecurity Law Blog
AWS News Blog
AWS News Blog
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Google DeepMind News
Google DeepMind News
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
有赞技术团队
有赞技术团队
酷 壳 – CoolShell
酷 壳 – CoolShell
C
Check Point Blog
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Security Archives - TechRepublic
Security Archives - TechRepublic
Apple Machine Learning Research
Apple Machine Learning Research
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
S
Security Affairs
Cyberwarzone
Cyberwarzone
V
Vulnerabilities – Threatpost
C
Cyber Attacks, Cyber Crime and Cyber Security
H
Hackread – Cybersecurity News, Data Breaches, AI and More
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
爱范儿
爱范儿
Spread Privacy
Spread Privacy
Recent Commits to openclaw:main
Recent Commits to openclaw:main
阮一峰的网络日志
阮一峰的网络日志
The GitHub Blog
The GitHub Blog
C
CERT Recently Published Vulnerability Notes
IT之家
IT之家
月光博客
月光博客
雷峰网
雷峰网
博客园 - 【当耐特】
Stack Overflow Blog
Stack Overflow Blog
美团技术团队
NISL@THU
NISL@THU
U
Unit 42
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报

博客园 - Kain

Microsoft.Practices.Unity 的一个线程安全Bug浅析 NET Reflector 7发布,其 不再免费 (抽象)工厂的另一种实现方式 自定义EF4 Model 代码生成 .net 4.0 中对多线程新特性(四)--任务和任务工厂 .net 4.0 中对多线程新特性(三) .net 4.0 中对多线程新特性(二) .net 4.0 中对多线程新特性(一) Flex&.Net开篇 SqlSever N层表数据查询效率 [读书笔记]Start-up fatigue(启动杂役) 马上又要过中秋和国庆了! 一个小问题 C#2.0 新的关键字 yield 我们的游戏! 不知道有没有同在学习aspnetforums的 郁闷! 关于面试 开心就好!
关于DataGride的Key事件
Kain · 2004-02-20 · via 博客园 - Kain

由于DataGride的外观是由Style来实现的所以没有办法捕获到DataGride的键盘和鼠标的相关事件。如果通过重写ColumeSytle来实现就太麻烦了。其实通过System.Windows.Forms.IMessageFilter来实现就很简单了。这里只简单的实现Key_Down事件,其他的都差不多,所以不在这占地方了。

/////============================

using System;
using System.Windows.Forms;

namespace 文件读写
{
 /// <summary>
 /// ExtendDataGrid 的摘要说明。
 /// </summary>
 public class ExtendDataGrid:System.Windows.Forms.DataGrid,System.Windows.Forms.IMessageFilter
 {
  
  public ExtendDataGrid()
  {

   //添加消息筛选器以便在向目标传送 Windows 消息时监视这些消息
   Application.AddMessageFilter(this);
   //
   // TODO: 在此处添加构造函数逻辑
   //
  }
  #region IMessageFilter 成员

  public bool PreFilterMessage(ref Message m)
  {
   // TODO:  添加 ExtendDataGrid.PreFilterMessage 实现
   if ((int)m.Msg==(int)Win32.Msgs.WM_KEYDOWN)
   {
    
    System.Windows.Forms.Keys k=(System.Windows.Forms.Keys)(int)m.WParam ;
    KeyEventArgs e = new KeyEventArgs(k);
    OnKeyDown(e);
    Console.WriteLine("Key is Pressed downd");
   }
   return false;
  }

  protected override void OnKeyDown(KeyEventArgs e)
  {
   base.OnKeyDown (e);
  }