如 一个DataGridView有若干条数据,我用小键盘的上下左右四个键可以切换DataGridView中的数据行
问 如何使用Button控件实现同样功能感谢达人解答!

解决方案 »

  1.   

    用BindingSource做DataGridView的数据源,再用你的数据做BindingSource的数据源,操作BindingSource
    比如,往下走一行,就是BingdingSource.MoveNext()
      

  2.   

    用BindingSource做DataGridView的数据源,再用你的数据做BindingSource的数据源,操作BindingSource
    比如,往下走一行,就是BingdingSource.MoveNext()
      

  3.   

      private void button_left_Click(object sender, EventArgs e)
            {
                int cIndex = this.dataGridView1.CurrentCell.ColumnIndex;
                int rowIndex = this.dataGridView1.CurrentCell.RowIndex;
                if (cIndex < this.dataGridView1.ColumnCount - 1)
                    cIndex++;
                this.dataGridView1.CurrentCell = this.dataGridView1.Rows[rowIndex].Cells[cIndex];
                this.dataGridView1.Focus();        }        private void button_right_Click(object sender, EventArgs e)
            {
                int cIndex = this.dataGridView1.CurrentCell.ColumnIndex;
                int rowIndex = this.dataGridView1.CurrentCell.RowIndex;
                if (cIndex >0)
                    cIndex--;
                this.dataGridView1.CurrentCell = this.dataGridView1.Rows[rowIndex].Cells[cIndex];
                this.dataGridView1.Focus();
            }上下button控制类似.