Reputation: 21
I'm working on a FlowLayoutPanel that has the capability of loading hundreds/thousands of custom user controls, each having a PictureBox and many text fields/buttons. I was able to implement virtual paging as seen here which works wonderfully, but I had to make some adjustments. The scrollbar inside the FlowLayoutPanel kept disappearing when the data changed, so I had to create a scrollbar outside the FlowLayoutPanel.
The issue I'm running into is this - the scroll bar won't scroll via mouse wheel when my mouse is anywhere outside of it. I tried making a MouseHover event on the FlowLayoutPanel and setting the focus to my scrollbar, but that didn't work. Any ideas on how I could get the scrollbar to scroll anywhere on the form?
Here's the virtual paging event from the link that I implemented:
private void vScrollBar1_Scroll(object sender, ScrollEventArgs e)
{
int pageSize = flowLayoutPanel1.ClientSize.Height / 500;
int v = Math.Min(userControlList.Count, vScrollBar1.Value);
flowLayoutPanel1.SuspendLayout();
flowLayoutPanel1.Controls.Clear();
flowLayoutPanel1.Controls.AddRange(userControlList.Skip((v - 1) * pageSize)
.Take(pageSize + 1).ToArray());
flowLayoutPanel1.ResumeLayout();
}
Upvotes: 1
Views: 424