private void bntNext_Click(object sender, EventArgs e)
        {
            if (dataGridView1.Rows.Count > 0)
            {
                if (dataGridView1.CurrentCell.RowIndex != dataGridView1.Rows.Count - 1)
                {
                    int last = dataGridView1.CurrentRow.Index;
                    dataGridView1.CurrentCell = dataGridView1.Rows[last + 1].Cells[0];
                }
                else
                {
                    dataGridView1.CurrentCell = dataGridView1.Rows[0].Cells[0];
                }
            }
        }

        private void btnPre_Click(object sender, EventArgs e)
        {
            try
            {
                if (dataGridView1.CurrentCell.RowIndex != 0)
                {
                    int last = dataGridView1.CurrentRow.Index;
                    dataGridView1.CurrentCell = dataGridView1.Rows[last - 1].Cells[0];
                }
                else
                {
                    dataGridView1.CurrentCell = dataGridView1.Rows[dataGridView1.Rows.Count - 1].Cells[0];
                }
            }
            catch { }
        }

posted on 2009-03-29 00:38  冷火  阅读(591)  评论(0编辑  收藏  举报