我想再DataGridView中的文本框中,输入一个值,然后在键盘上点击回车,就促发一个事件,要怎么做呢?
解决方案 »
- c++ sdk 函数 转为 c# 问题
- 急,急,急!求教数值分析里三次样条插值I型插值的csharp代码
- C# 贪吃蛇、坦克大战、俄罗斯方块怎么做,有个思路也好,感激不尽~!
- 关于"Windows Communication Foundation之旅"的例程DuplexSample.rar
- 程序打包问题!
- ComboBox的奇怪问题,路过有分,在线结贴
- 关于C# 中combobox selectedvalue 的问题
- 关于使用Infragistics的源代码的问题,“无法找到Infragistics.Shared”
- f1.Paint += new PaintEventHandler(f1_Paint); 中的 f1_Paint 可以带参数吗
- 谈谈asp.net Beta2 在商业应用中的可行性,请跟帖,精彩的送分!!!
- 急sql语句问题,请教大侠
- 如何让控件的大小与窗体大小成等比放大或缩小
if (e.KeyCode == Keys.Enter)
{
//操作
}
错了 时KeyDown事件Login是我Form的名字 - -。
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Threading;namespace WindowsApplication139
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent(); dataGridView1.EditingControlShowing += new DataGridViewEditingControlShowingEventHandler(dataGridView1_EditingControlShowing);
} void dataGridView1_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
{
// 如果已经包含这个事件则先删除,否则会加2次
e.Control.PreviewKeyDown -= new PreviewKeyDownEventHandler(Control_PreviewKeyDown);
e.Control.PreviewKeyDown += new PreviewKeyDownEventHandler(Control_PreviewKeyDown);
} void Control_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
{
if (e.KeyCode == Keys.Enter)
MessageBox.Show("!");
}
}
}