我有一个5列的datagridview,当我按"enter"它进入下一个单元格,当它到达行的末尾,当我按Enter键它添加一个新的行,但我的问题是当我移动到上一个我按下后输入它跳行,不会去下一个单元格,任何帮助?
public partial class Form1 : Form
{
public static int Col;
public static int Row;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
dataGridView1.AllowUserToAddRows = false;
dataGridView1.Rows.Add();
}
private void dataGridView1_CellEnter(object sender, DataGridViewCellEventArgs e)
{
Col = dataGridView1.CurrentCellAddress.X;
Row = dataGridView1.CurrentCellAddress.Y;
}
private void Form1_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == (int)Keys.Enter)
{
if (Col + 1 < 5)
{
dataGridView1.CurrentCell = dataGridView1[Col + 1, Row];
}
else
{
dataGridView1.Rows.Add();
dataGridView1.CurrentCell = dataGridView1[Col - …Run Code Online (Sandbox Code Playgroud)