private void button2_Click(object sender, EventArgs e)
        {
            if (dataGridView1.CurrentCell.RowIndex !=0)
            {
                dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
                this.dataGridView1.CurrentCell = this.dataGridView1[this.dataGridView1.CurrentCell.ColumnIndex, this.dataGridView1.CurrentCell.RowIndex - 1];
                textBox1.Text = dataGridView1.Rows[dataGridView1.CurrentCell.RowIndex].Cells[0].Value.ToString();
            }
            else
            {
                MessageBox.Show("第一条数据");
            }
        }

        private void button3_Click(object sender, EventArgs e)
        {
            if (dataGridView1.CurrentCell.RowIndex != dataGridView1.RowCount - 1)
            {
                dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
                this.dataGridView1.CurrentCell = this.dataGridView1[this.dataGridView1.CurrentCell.ColumnIndex, this.dataGridView1.CurrentCell.RowIndex + 1];
                textBox1.Text = dataGridView1.Rows[dataGridView1.CurrentCell.RowIndex].Cells[0].Value.ToString();
            }
            else
            {
                MessageBox.Show("最后一条记录");
            }
        }

相关文章:

  • 2022-12-23
  • 2022-03-10
  • 2022-12-23
  • 2021-08-10
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-11-03
  • 2022-02-14
  • 2022-12-23
  • 2021-07-14
  • 2021-10-04
  • 2021-12-10
相关资源
相似解决方案