Flowlayoutpanel用鼠标滚动许多控件

问题描述

我有一个用用户控件填充的列表(〜300个用户控件//每个UC都有一个PictureBox和10个标签)。我将它们全部显示在Flowlayoutpanel中,但是当我向下或向上滚动时,它非常慢并且有点无响应。我已经在使用DoubleBuffered Flowlayoutpanel和SuspendLayout和ResumeLayout的“技巧”。我想做的是:我用鼠标向下滚动->当前两个用户控件不在视图中时,将它们删除->从底部的列表中添加两个新的用户控件。这也应该以相反的方式起作用:用鼠标向上滚动->当视图中不再有最后两个时,将其删除->从顶部的列表中添加两个新的用户控件。 Picture

我检查并尝试了发现的所有内容,但均无法正常工作... 我检查了一些链接:

 private void FlowLayoutPanel_MouseMove(object sender,MouseEventArgs e)
        {
            // move flowlayoutpanel with mouse
            if (e.Button != MouseButtons.Left)
                return;

            Point pointDifference = new Point(Cursor.Position.X + mouseDownPoint.X,Cursor.Position.Y - mouseDownPoint.Y);
            if ((mouseDownPoint.X == Cursor.Position.X) && (mouseDownPoint.Y == Cursor.Position.Y))
                return;

            Point currAutoScroll = FlowLayoutPanel.AutoScrollPosition;
            FlowLayoutPanel.AutoScrollPosition = new Point(Math.Abs(currAutoScroll.X) - pointDifference.X,Math.Abs(currAutoScroll.Y) - pointDifference.Y);
            mouseDownPoint = Cursor.Position;

            
            //
            Point locationOnForm = UClist[0].FindForm().PointToClient(
            UClist[0].Parent.PointToScreen(new Point(UClist[0].Location.X,UClist[0].Location.Y+300)));
            if (locationOnForm.Y < 190)
            {
                FlowLayoutPanel.SuspendLayout();
                FlowLayoutPanel.Controls.Clear();
                FlowLayoutPanel.Controls.AddRange(UClist.Skip(2).Take(2).ToArray());
                FlowLayoutPanel.ResumeLayout();
            }   
        }

我应该怎么办?

编辑 这就是我说的“回合”

Pic

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...