好像现在都没有什么完整的这类答案。
//首记录
private void btnTop_Click(object sender, System.EventArgs e)
{
dataGridC.CurrentRowIndex = 0;
UnselectAllC();
dataGridC.Select(0);
}
//尾记录
private void btnBottom_Click(object sender, System.EventArgs e)
{
dataGridC.CurrentRowIndex = dataSetTypes.Tables["ChangeTypes"].Rows.Count - 1;
UnselectAllC();
dataGridC.Select(dataSetTypes.Tables["ChangeTypes"].Rows.Count - 1);
}
//上一条
private void btnPrevious_Click(object sender, System.EventArgs e)
{
if(dataGridC.CurrentRowIndex <= 0)
{
MessageBox.Show("索引已经超出数组界限,不能再向上。");
btnPrevious.Enabled = false;
btnNext.Enabled = true;
}
else
{
dataGridC.CurrentRowIndex -= 1;
UnselectAllC();
dataGridC.Select(dataGridC.CurrentRowIndex);
}
}
//下一条
private void btnNext_Click(object sender, System.EventArgs e)
{
if(dataGridC.CurrentRowIndex >= dataSetTypes.Tables["ChangeTypes"].Rows.Count-1)
{
MessageBox.Show("索引已经超出数组界限,不能再向下。");
btnNext.Enabled = false;
btnPrevious.Enabled = true;
}
else
{
dataGridC.CurrentRowIndex += 1;
UnselectAllC();
dataGridC.Select(dataGridC.CurrentRowIndex);
}
}
[此贴子已经被作者于2007-8-7 13:30:24编辑过]