首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

c#键盘事件,为什么小弟我的程序没反应

2012-11-05 
c#键盘事件,为什么我的程序没反应using Systemusing System.Collections.Genericusing System.Component

c#键盘事件,为什么我的程序没反应
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace 123
{
  public partial class Form1 : Form
  {
  public Form1()
  {
  InitializeComponent();
  }
  private void Form1_KeyPress(object sender,KeyPressEventArgs e)
  {
  if (e.KeyChar == (char)Keys.Enter)
  label1.Text = "你按下了〈Enter〉键";  
  }

  }
}


[解决办法]
用全局钩子 或者 在你所有的鼠标能点击到的控件上 都要加上监听

热点排行