C# 自动滚屏

来源:百度知道 编辑:UC知道 时间:2024/05/24 10:53:11
C#的winform的程序里,应该用什么样的控件来滚屏显示大量的记录。
最近在做一个抽奖小程序,由于中奖人数过多,无法一屏显示,我用了listView控件来显示记录,出现了滚动条,但我想让中奖人员的名单可以滚动形式的显示,请问应该如何处理这个问题,最好有代码哦。或者是换什么样的控件可以实现这个滚屏显示功能。

用个timmer

timer1.Interval = 100;
timer1.Enabled = true;
listView1.HideSelection = true;

private void timer1_Tick(object sender, EventArgs e)
{
if (listView1.Items.Count == 0)
{
return;
}

if (listView1.SelectedItems.Count == 0)
{
listView1.Items[0].Selected=true;
listView1.Items[0].Focused = true;
listView1.Items[0].EnsureVisible();
}
else
{

int index = listView1.SelectedItems[0].Index+1;
listView1.SelectedItems[0].Selected = false;
if (index >= listView1.Items.Count)
{
index = 0;
}
listView1.Items[index].Selected=true;