I want to disable mouse wheel in UltraComboEditor. In other words, I don't want user to select the item by mouse wheel, they can just select item from drop down list. I've tried many ways and all failed. But MS comboBox can handle everything as I want.
Then I made an experiment between MS comboBox and UltraComboEditor. I find that UltraComboEditor can not handle mouse wheel event while MS comboBox can. I tried 3 ways to debug whether this control can capture mouse wheel event. Blow is the 3 ways of my experiment. I set several breakponts to ensure combobox can handle mouse wheel event. MS combo can enter all the breakponts but UltraCombo can't. Anyone can help me?
const int WM_MOUSEWHEEL = 0x020A;
protected override void WndProc(ref Message m) { //stop scroll if (m.Msg == WM_MOUSEWHEEL) { //but force next item int delta; if ((int)m.WParam > 0) { //up delta = 1; } else { //down delta = -1; } this.OnMouseWheel(new MouseEventArgs(MouseButtons.None, 0, 0, 0, delta));
return; }
base.WndProc(ref m); }
protected override void OnMouseWheel(MouseEventArgs e) { base.OnMouseWheel(e); }
public Form1() { this.testUltraCmb1.MouseWheel += new MouseEventHandler(testUltraCmb1_MouseWheel); }
public void testUltraCmb1_MouseWheel(object sender, MouseEventArgs e) { HandledMouseEventArgs handledArgs = e as HandledMouseEventArgs; if (handledArgs != null) handledArgs.Handled = true; }
A Solution (VS 2008) is attached.
Can you post a small sample project? It's very difficult to take code like this and create a project around it since it does not include any solution or project file which have valuable information.
Here is the complete code. The version number of the Infragistics controls I used is 20082.2194. When the Form opens, UltraComboEditor gets focus.Turn the mouse wheel with the mouse pointer anywhere on the screen.
public class Form1 : Form { public Form1() { InitializeComponent(); }
private System.ComponentModel.IContainer components = null;
protected override void Dispose(bool disposing) { if (disposing && (components != null)) { components.Dispose(); } base.Dispose(disposing); }
#region Windows Form Designer generated code private void InitializeComponent() { Infragistics.Win.ValueListItem valueListItem1 = new Infragistics.Win.ValueListItem(); Infragistics.Win.ValueListItem valueListItem2 = new Infragistics.Win.ValueListItem(); Infragistics.Win.ValueListItem valueListItem3 = new Infragistics.Win.ValueListItem(); Infragistics.Win.ValueListItem valueListItem4 = new Infragistics.Win.ValueListItem(); this.ultraComboEditor1 = new Infragistics.Win.UltraWinEditors.UltraComboEditor(); ((System.ComponentModel.ISupportInitialize)(this.ultraComboEditor1)).BeginInit(); this.SuspendLayout(); // // ultraComboEditor1 // valueListItem1.DataValue = 1; valueListItem1.DisplayText = "Item1"; valueListItem2.DataValue = 2; valueListItem2.DisplayText = "Item2"; valueListItem3.DataValue = 3; valueListItem3.DisplayText = "Item3"; valueListItem4.DataValue = 4; valueListItem4.DisplayText = "Item4"; this.ultraComboEditor1.Items.AddRange(new Infragistics.Win.ValueListItem[] { valueListItem1, valueListItem2, valueListItem3, valueListItem4}); this.ultraComboEditor1.Location = new System.Drawing.Point(12, 12); this.ultraComboEditor1.Name = "ultraComboEditor1"; this.ultraComboEditor1.Size = new System.Drawing.Size(260, 21); this.ultraComboEditor1.TabIndex = 0; this.ultraComboEditor1.Text = "Item1"; // // Form1 // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(284, 264); this.Controls.Add(this.ultraComboEditor1); this.Name = "Form1"; this.Text = "Form1"; this.Load += new System.EventHandler(this.Form1_Load); ((System.ComponentModel.ISupportInitialize)(this.ultraComboEditor1)).EndInit(); this.ResumeLayout(false); this.PerformLayout();
}
#endregion
private Infragistics.Win.UltraWinEditors.UltraComboEditor ultraComboEditor1;
private void Form1_Load(object sender, EventArgs e) { this.ultraComboEditor1.ControlAdded += new ControlEventHandler(ultraComboEditor1_ControlAdded); this.ultraComboEditor1.ControlRemoved += new ControlEventHandler(ultraComboEditor1_ControlRemoved); }
void ultraComboEditor1_ControlRemoved(object sender, ControlEventArgs e) { TextBox textBox = e.Control as TextBox; if (textBox != null) textBox.MouseWheel -= new MouseEventHandler(ultraComboEditor1_MouseWheel); }
void ultraComboEditor1_ControlAdded(object sender, ControlEventArgs e) { TextBox textBox = e.Control as TextBox; if (textBox != null) textBox.MouseWheel += new MouseEventHandler(ultraComboEditor1_MouseWheel); }
void ultraComboEditor1_MouseWheel(object sender, MouseEventArgs e) { HandledMouseEventArgs handledArgs = e as HandledMouseEventArgs; if (handledArgs != null) handledArgs.Handled = true;
MessageBox.Show("MouseWheel is called AFTER the scroll!"); } }
Hi,
As I said, I tried this out and it worked fine for me. So if this is happening, we will need to be able to duplicate it. Can you provide a small sample project demonstrating the issue and post it here so we can check it out?
Mike,
I applied the latest available Service Release (Version 20082.2194), but the problem persists.Just like imissfm reported UltraComboEditor scrolls first and then enters the MouseWheel event, which is too late to prevent the scroll.