June 22, 2013 by Nitesh

How to Disable Mouse Scroll in DevExpress LookupEdit Control


LookupEdit is another one of the most commonly used controls in DevExpress WinForms library as it resembles the default ComoboBox control provided in the default .Net Toolbox. As compared to normal Combobox control, you can display rows of data in a LookupEdit Control. The control by default support AutoComplete feature so when you start typing on the control, the best matches are shown. A sample LookupEdit control in action is shown below – lookupedit

Scrolling the mouse wheel when the control is the active control allows you to change values smoothly without any hassles. This is a very good feature, but in some cases, we do not want this feature to be used by the end users. This post will explain how can we disable MouseScrolling on the LookupEdit control.

To disable the mouse scrolling on LookupEdit control, we will handle the MouseWheel Event of the control. This event is fired whenever the mouse wheel is scrolled and the control is the active control.

Let us take an example we have a LookupEdit control on the form and its name is tbEdit.

Write the below code in your Form_Load() and then write the MouseWheel() event handler as below.

VB.Net Version

Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
      AddHandler tbEdit.MouseWheel, AddressOf tbEdit_MouseWheel    
End Sub

Private Sub tbEdit_MouseWheel(sender As Object, e As MouseEventArgs)
      DevExpress.Utils.DXMouseEventArgs.GetMouseArgs(e).Handled = True
End Sub

C# Version

private void Form1_Load(object sender, System.EventArgs e)
	tbEdit.MouseWheel += tbEdit_MouseWheel;

private void tbEdit_MouseWheel(object sender, MouseEventArgs e)
	DevExpress.Utils.DXMouseEventArgs.GetMouseArgs(e).Handled = true;

You’re done. Run your application and try scrolling the mouse by focusing on the control. You won’t be able to.

In case you want to enable this feature on DevExpress’s TextEdit control, have a look at this link.

Hope you like this post. Please let me know your thoughts via comments or contact me here.


Support us!

If you like this site please help and make click on any of these buttons!

Powered by WordPress Popup