這是我的代碼:
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 的樣子:

當我在 flowlayoutpanel 內使用滑鼠滾輪滾動時,滾動事件似乎沒有被觸發
解決方案應該不難找到,但是我堅持了幾個小時.. 誰能給我一些指導?謝謝!!
uj5u.com熱心網友回復:
有一個特殊的MouseWheel事件可以捕捉到這個
flowLayoutPanel1.MouseWheel = FlowLayoutPanel1_MouseWheel;
private void FlowLayoutPanel1_MouseWheel(object sender, MouseEventArgs e)
{
Console.WriteLine("Scrolling Wheel");
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/420771.html
標籤:
下一篇:C#應用程式中沒有釋放記憶體
