这是我的密码:
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");
}
}下面是UI的样子:

当我在流布局面板内用鼠标滚动时,滚动事件似乎不会被触发。
解决办法应该不难找到,但我坚持了几个小时。有人能给我指路吗?谢谢!!
发布于 2022-01-25 06:58:43
有一个特殊的MouseWheel事件可以捕捉到
flowLayoutPanel1.MouseWheel += FlowLayoutPanel1_MouseWheel;
private void FlowLayoutPanel1_MouseWheel(object sender, MouseEventArgs e)
{
Console.WriteLine("Scrolling Wheel");
}https://stackoverflow.com/questions/70843627
复制相似问题