问题描述
我有一个用用户控件填充的列表(〜300个用户控件//每个UC都有一个PictureBox和10个标签)。我将它们全部显示在Flowlayoutpanel中,但是当我向下或向上滚动时,它非常慢并且有点无响应。我已经在使用DoubleBuffered Flowlayoutpanel和SuspendLayout和ResumeLayout的“技巧”。我想做的是:我用鼠标向下滚动->当前两个用户控件不在视图中时,将它们删除->从底部的列表中添加两个新的用户控件。这也应该以相反的方式起作用:用鼠标向上滚动->当视图中不再有最后两个时,将其删除->从顶部的列表中添加两个新的用户控件。 Picture
我检查并尝试了发现的所有内容,但均无法正常工作... 我检查了一些链接:
- Fake-scrolling containers with very many controls
- https://social.msdn.microsoft.com/Forums/en-US/bc881e4d-6770-44f0-85ce-51456920f938/adding-4000-child-controls-to-flowlayoutpanel-freezez-the-scrolling?forum=winforms
- Populating a FlowLayoutPanel with a large number of controls and painting thumbnails on demand
- How can i implement the paging effect in a FlowLayoutPanel control?
- Winforms: Scrollable FlowLayoutPanel with thousands of user controls - How to prevent memory leaks and dispose objects the right way?
- https://www.dreamincode.net/forums/topic/381141-flowlayoutpanel-paging-effect/
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();
}
}
我应该怎么办?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)