L'evento MouseWheel non viene attivato quando si utilizza qualsiasi controllo (ListBox, Panel, TextBox) con le barre di scorrimento.L'evento MouseWheel non si attiva quando si utilizza qualsiasi controllo con gli strumenti di scorrimento (in C# Windows Form)
per riprodurre il problema:
public class Form1 : Form
{
private readonly Button button1;
private readonly TextBox textBox1;
private void button1_MouseWheel(object sender, MouseEventArgs e)
{
ToString(); // doesn't fire when uncomment lines below
}
public Form1()
{
button1 = new Button();
textBox1 = new TextBox();
SuspendLayout();
button1.Location = new System.Drawing.Point(80, 105);
button1.Size = new System.Drawing.Size(75, 23);
button1.MouseWheel += button1_MouseWheel;
button1.Click += button1_Click;
textBox1.Location = new System.Drawing.Point(338, 105);
//textBox1.Multiline = true; // uncomment this
//textBox1.ScrollBars = ScrollBars.Vertical; // uncomment this
textBox1.Size = new System.Drawing.Size(100, 92);
ClientSize = new System.Drawing.Size(604, 257);
Controls.Add(textBox1);
Controls.Add(button1);
ResumeLayout(false);
PerformLayout();
}
// Clicking the button sets Focus, but even I do it explicit Focus() or Select()
// still doesn't work
private void button1_Click(object sender, System.EventArgs e)
{
button1.Focus();
button1.Select();
}
}
Forse il problema è nel topo, io uso "Lenovo USB Optical Wheel Mouse" (configurazione di default "Interasse Pulsante" Funzione "Quick/AutoScroll") – halorty
che uso: Windows Vista Buisness, .Net Framework 3.5 SP1 , Visual Studio 2008 Standard Edition (tutti gli hotfix ufficiali). Build Debug: Target Framework = .Net Framework 3.5, Tipo di output = Applicazione Windows – halorty
Configurazione mouse: Pannello di controllo/Mouse/Ruota/Whell-> Abilita scorrimento universale; Pannello di controllo/Mouse/Ruota/Pulsante Whell-> Quick/AutoScrol; Pannello di controllo/Mouse/Ruota/Velocità di scorrimento-> Scorrimento = 10 linea/e per noth; – halorty