zoukankan      html  css  js  c++  java
  • datagridview 上一条数据,下一条数据实现

    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("最后一条记录");
                }
            }

  • 相关阅读:
    软件工程概论-用户登录界面
    2016.11.25异常处理
    2016.11.18多态
    2016.11.11继承与接口
    11.6数组
    10.28字符串加密等
    python 读写文件
    python可变的类型、不可变的类型
    python 字典练习 记录学生是否交作业的小程序
    python字典
  • 原文地址:https://www.cnblogs.com/tianguook/p/2540660.html
Copyright © 2011-2022 走看看