Here's my code:
public partial class Form1 : Form {
public Form1() {
InitializeComponent();
for (int i = 0; i < 10; i ) {
Button btn = new Button();
btn.Text = "TEST";
btn.Height = 35;
this.flowLayoutPanel1.Controls.Add(btn);
}
this.flowLayoutPanel1.AutoScroll = true;
this.flowLayoutPanel1.Scroll = FlowLayoutPanel1_Scroll;
}
private void FlowLayoutPanel1_Scroll(object sender, ScrollEventArgs e) {
MessageBox.Show("Event Triggered");
}
}
And here's what the UI look like:
The scroll event just seems not be triggered while I scroll with mouse wheel inside the flowlayoutpanel
The solution shouldn't be hard to find, however I stuck on it for hours.. Can anyone point me some directions? Thanks!!
CodePudding user response:
there is a special MouseWheel event that captures this
flowLayoutPanel1.MouseWheel = FlowLayoutPanel1_MouseWheel;
private void FlowLayoutPanel1_MouseWheel(object sender, MouseEventArgs e)
{
Console.WriteLine("Scrolling Wheel");
}