/// <summary>
/// 设置自动跳行选择
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
int index = 0;//dgv索引
bool b = false;//判断是否未向下滚或向上滚
//int index=0;
private void timer3_Tick(object sender, EventArgs e)
{
if (this.dataGridView2.Rows.Count > 0)
{
int count = this.dataGridView2.Rows.Count - 1;
if (index > count)
{
// b = true;//往上滚
// index= this.dataGridView1.Rows.Count - 1;
b = false;//往下滚
dataGridView2.Rows[index - 1].Selected = false;
index = 0;
}
else if (index <= 0)
{
b = false;//往下滚
index = 0;
}
if (b)
{
index--;
dataGridView2.Rows[index].Selected = true;//选择行
if (index != count)
dataGridView2.Rows[index + 1].Selected = false;//取消选中行
dataGridView1.FirstDisplayedScrollingRowIndex = index;
}
else
{
dataGridView2.Rows[index].Selected = true;
if (index != 0)
dataGridView2.Rows[index - 1].Selected = false;
dataGridView2.FirstDisplayedScrollingRowIndex = index;
index++;
}
}
timer3.Enabled = false;
EnableTimer();
}
private void EnableTimer()
{
timer3.Enabled = true;
}