try
{
//int ColInd = 0;
//if (dataGridView1.CurrentCell.ColumnIndex == -1 || dataGridView1.CurrentCell.ColumnIndex > 1)
// ColInd = 0;
//else
// ColInd = dataGridView1.CurrentCell.ColumnIndex;
if ((((ToolStripButton)sender).Name) == "N_First")
{
dataGridView1.CurrentCell = this.dataGridView1[ColInd, 0];
MyMC.Ena_Button(N_First, N_Previous, N_Next, N_Cauda, 0, 0, 1, 1);
}
if ((((ToolStripButton)sender).Name) == "N_Previous")
{
if (dataGridView1.CurrentCell.RowIndex == 0)
{
MyMC.Ena_Button(N_First, N_Previous, N_Next, N_Cauda, 0, 0, 1, 1);
}
else
{
dataGridView1.CurrentCell = this.dataGridView1[ColInd, dataGridView1.CurrentCell.RowIndex - 1];
MyMC.Ena_Button(N_First, N_Previous, N_Next, N_Cauda, 1, 1, 1, 1);
}
}
if ((((ToolStripButton)sender).Name) == "N_Next")
{
if (dataGridView1.CurrentCell.RowIndex == dataGridView1.RowCount - 2)
{
MyMC.Ena_Button(N_First, N_Previous, N_Next, N_Cauda, 1, 1, 0, 0);
}
else
{
dataGridView1.CurrentCell = this.dataGridView1[ColInd, dataGridView1.CurrentCell.RowIndex + 1];
MyMC.Ena_Button(N_First, N_Previous, N_Next, N_Cauda, 1, 1, 1, 1);
}
}
if ((((ToolStripButton)sender).Name) == "N_Cauda")
{
dataGridView1.CurrentCell = this.dataGridView1[this.dataGridView1.CurrentCell.ColumnIndex, dataGridView1.RowCount - 1];
MyMC.Ena_Button(N_First, N_Previous, N_Next, N_Cauda, 1, 1, 0, 0);
}
}
catch (Exception ex)
{
Cursor = Cursors.Default;
ExceptionExt.ShowExceptionMessage(ex);
}DataGridView异常
{
//int ColInd = 0;
//if (dataGridView1.CurrentCell.ColumnIndex == -1 || dataGridView1.CurrentCell.ColumnIndex > 1)
// ColInd = 0;
//else
// ColInd = dataGridView1.CurrentCell.ColumnIndex;
if ((((ToolStripButton)sender).Name) == "N_First")
{
dataGridView1.CurrentCell = this.dataGridView1[ColInd, 0];
MyMC.Ena_Button(N_First, N_Previous, N_Next, N_Cauda, 0, 0, 1, 1);
}
if ((((ToolStripButton)sender).Name) == "N_Previous")
{
if (dataGridView1.CurrentCell.RowIndex == 0)
{
MyMC.Ena_Button(N_First, N_Previous, N_Next, N_Cauda, 0, 0, 1, 1);
}
else
{
dataGridView1.CurrentCell = this.dataGridView1[ColInd, dataGridView1.CurrentCell.RowIndex - 1];
MyMC.Ena_Button(N_First, N_Previous, N_Next, N_Cauda, 1, 1, 1, 1);
}
}
if ((((ToolStripButton)sender).Name) == "N_Next")
{
if (dataGridView1.CurrentCell.RowIndex == dataGridView1.RowCount - 2)
{
MyMC.Ena_Button(N_First, N_Previous, N_Next, N_Cauda, 1, 1, 0, 0);
}
else
{
dataGridView1.CurrentCell = this.dataGridView1[ColInd, dataGridView1.CurrentCell.RowIndex + 1];
MyMC.Ena_Button(N_First, N_Previous, N_Next, N_Cauda, 1, 1, 1, 1);
}
}
if ((((ToolStripButton)sender).Name) == "N_Cauda")
{
dataGridView1.CurrentCell = this.dataGridView1[this.dataGridView1.CurrentCell.ColumnIndex, dataGridView1.RowCount - 1];
MyMC.Ena_Button(N_First, N_Previous, N_Next, N_Cauda, 1, 1, 0, 0);
}
}
catch (Exception ex)
{
Cursor = Cursors.Default;
ExceptionExt.ShowExceptionMessage(ex);
}DataGridView异常
{
int rowNum = 1;
lbl行号.Text = Convert.ToString(rowNum);
dgvRPG(dgv, rowNum);
}private void btn上一记录File_Click(object sender, EventArgs e)
{
int rowNum = Convert.ToInt32(lbl行号.Text);
if (rowNum - 1 < 1)
rowNum = 1;
else
rowNum = rowNum - 1;
lbl行号.Text = Convert.ToString(rowNum);
dgvRPG(dgv, rowNum);
}private void btn下一记录File_Click(object sender, EventArgs e)
{
int rowNum = Convert.ToInt32(lbl行号.Text);
if (rowNum + 1 > dgv.Rows.Count)
rowNum = dgv.Rows.Count;
else
rowNum = rowNum + 1;
if (rowNum < 1)
rowNum = 1;
lbl行号.Text = Convert.ToString(rowNum);
dgvRPG(dgv, rowNum);
}private void btn尾记录File_Click(object sender, EventArgs e)
{
int rowNum = dgv.Rows.Count;
if (rowNum < 1)
rowNum = 1;
lbl行号.Text = Convert.ToString(rowNum);
dgvRPG(dgv, rowNum);
}public void dgvRPG(DataGridView dgv, int rowNum)
{
try
{
if (dgv.CurrentCell != null)
{
dgv.ClearSelection();
dgv.Rows[rowNum - 1].Cells[dgv.CurrentCell.ColumnIndex].Selected = true;
dgv.CurrentCell = dgv.Rows[rowNum - 1].Cells[dgv.CurrentCell.ColumnIndex];
}
}
catch
{ }
}