zoukankan      html  css  js  c++  java
  • 在datagridview控件中按Enter键时,将焦点设置为下一个单元格(Set focus to next cell when pressing enter key in datagridview control)

    private void dataGridView1_KeyDown(object sender, KeyEventArgs e)
            {
    
                if (e.KeyCode == Keys.Enter)
                {
                    e.SuppressKeyPress = true;
                    int iColumn = dataGridView1.CurrentCell.ColumnIndex;
                    int iRow = dataGridView1.CurrentCell.RowIndex;
                    if (iColumn == dataGridView1.Columns.Count - 1)
                        dataGridView1.CurrentCell = dataGridView1[0, iRow + 1];
                    else
                        dataGridView1.CurrentCell = dataGridView1[iColumn + 1, iRow];
    
                }
            }

    private void dataGridView1_KeyDown( object sender,KeyEventArgs e)
    {

    if (e.KeyCode == Keys.Enter)
    {
    e .SuppressKeyPress = true ;
    int iColumn = dataGridView1.CurrentCell.ColumnIndex;
    int iRow = dataGridView1.CurrentCell.RowIndex;
    if (iColumn == dataGridView1.Columns.Count - 1 )
    dataGridView1 .CurrentCell = dataGridView1 [ 0 ,iRow + 1 ];
    else
    dataGridView1.CurrentCell = dataGridView1 [iColumn + 1 ,iRow];

    }
    }
  • 相关阅读:
    |,&,<<,>>运算符
    Unity 异步加载场景
    string字母排序,
    冒泡算法
    Direct3D 12 编程---(1)
    点云密度粗估计
    git工具使用
    opencv---灰度图像与彩色图像遍历
    求平面两直线的交点,两直线段的交点
    结构体重载运算符
  • 原文地址:https://www.cnblogs.com/skynight/p/14330459.html
Copyright © 2011-2022 走看看