1、首先是换行问题!
DataGridView中,你输入数据,按回车,不会跳到下一列去,而是跳到下一行,如果你想通过KeyPress,KeyDown,KeyUp事件达到目的,好像没什么反应。于是我想肯定有其他的方法可以解决。就到微软的网站上去查,果然有相关情况的介绍,但还是达不到我要的,于是改造一下,就OK了。
基本解决方法如下:
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
namespace WindowsApplication1
...{
public class CustomDataGridView : DataGridView
...{
protected override bool ProcessDialogKey(Keys keyData)
...{
Keys key = (keyData & Keys.KeyCode);
if (key == Keys.Enter)
...{
return this.ProcessRightKey(keyData);
}
return base.ProcessDialogKey(keyData);
}
public new bool ProcessRightKey(Keys keyData)
.