在C#winform窗体下
我想在dataGridView1,编辑某单元格后,按enter,比如执行
if (e.KeyChar == '\r')
{
MessageBox.Show("你好");
}
也就是要监听enter事件。现在是无论我怎么写,按enter读是自动换行到下一行的单元格。
请问:如何实现dataGridView1,编辑某单元格后,按enter,执行enter事件的内容。
我想在dataGridView1,编辑某单元格后,按enter,比如执行
if (e.KeyChar == '\r')
{
MessageBox.Show("你好");
}
也就是要监听enter事件。现在是无论我怎么写,按enter读是自动换行到下一行的单元格。
请问:如何实现dataGridView1,编辑某单元格后,按enter,执行enter事件的内容。
解决方案 »
- 客户端连接不了服务器端(c#,remoting问题)
- bool? 是什么类型? 不能转换为bool型
- 如何判断这个回文呢??
- TabPage的批量关闭方法
- 请教一个显示器的DPI设置问题,界面上的控件出现了错位,期待高手的回答。
- 个人源码网站http://lbh.8800.org 希望有些源码对大家有帮助!
- 关于用户点击退出按钮的问题.
- 怎样在C#中实现文件加密
- 请教高手:C#调用DLL的问题!
- 请教大虾们,TREEVIEW中的节点拖到PANEL中,使PANEL中的TEXT的文字为节点的文字,应该怎么操作啊?
- 我是新手,SendMassage发送组合键,比如Alt+E
- 简单的dataGridView1列切换焦点问题
你设置一个断点,看看是什么,在Keychar enum中好像也有,记不太清了。
private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == '\r')
{
MessageBox.Show("你好");
}
要实现这样的功能。但是在dataGridView1里,我选了好多事件,每次按enter都是换到下一行了。
private void dgvWR_CellLeave(object sender, DataGridViewCellEventArgs e)
{
MessageBox.Show(dgvWR.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString());
}
{
MessageBox.Show("你好");
}
protected override void OnKeyUp(System.Windows.Forms.KeyEventArgs e)
{ if (e.KeyCode == System.Windows.Forms.Keys.Enter)
{ e.Handled = true; }
} protected override bool ProcessCmdKey(ref System.Windows.Forms.Message msg, System.Windows.Forms.Keys keyData)
{
switch (keyData)
{
case System.Windows.Forms.Keys.Enter: if (dataGridView1.CurrentCell == dataGridView1.Rows[dataGridView1.CurrentCell.RowIndex].Cells[1])
{ dataGridView1.CurrentCell = dataGridView1.Rows[dataGridView1.CurrentCell.RowIndex].Cells[4];
}
else if (dataGridView1.CurrentCell.ColumnIndex == 4)
{
dataGridView1.CurrentCell = dataGridView1.Rows[dataGridView1 .CurrentCell .RowIndex+1 ].Cells[1];
}
return true;
}
return base.ProcessCmdKey(ref msg, keyData);
}