Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/amazon-s3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Winforms Windows窗体DataGridView滚动_Winforms_Datagridview - Fatal编程技术网

Winforms Windows窗体DataGridView滚动

Winforms Windows窗体DataGridView滚动,winforms,datagridview,Winforms,Datagridview,我希望在DataGridView中创建一种滑动滚动效果。我想向下滚动一行,但我想让它慢慢滑动,这样用户就可以清楚地看到它正在被滚动 这有可能吗?我发现可以使用FirstDisplayedScrollingRowIndex属性直接滚动到一行,但这并不是我想要的 编辑:我想如果我能找到一种方法在行边界之间滚动,我就能做到这一点。然后,我可以通过编程以小增量滚动几次,使其看起来像是在缓慢滚动 非常感谢您的帮助。因此我找到了一个可行的解决方案,尽管它不是一个很好的解决方案。下面的代码给出了DataGri

我希望在DataGridView中创建一种滑动滚动效果。我想向下滚动一行,但我想让它慢慢滑动,这样用户就可以清楚地看到它正在被滚动

这有可能吗?我发现可以使用FirstDisplayedScrollingRowIndex属性直接滚动到一行,但这并不是我想要的

编辑:我想如果我能找到一种方法在行边界之间滚动,我就能做到这一点。然后,我可以通过编程以小增量滚动几次,使其看起来像是在缓慢滚动


非常感谢您的帮助。

因此我找到了一个可行的解决方案,尽管它不是一个很好的解决方案。下面的代码给出了DataGridView中平滑滚动的外观

    //Insert Row at bottom of DataGridView with a row height of 0 here

    DataGridView1.Enabled = false;

    for (int i = 0; i < ROW_HEIGHT; i++)
    {
        DataGridView1.Rows[0].Height--;
        DataGridView1.Rows[LAST_ROW].Height++;
        Thread.Sleep(20);
    }

    DataGridView1.Enabled = true;

    // Remove first row in DataGridView here
//在DataGridView底部插入行,此处的行高为0
DataGridView1.Enabled=false;
对于(int i=0;i
此解决方案之所以有效,是因为每次添加新的DataGridView时,我都会删除DataGridView中的第一行,这就是为什么我可以慢慢将其降低到高度0,因为它无论如何都会被删除。这基本上给了我一个固定数量的行,基本上创建了一个固定大小的队列