Friends,
LookupEdit is another one of the most commonly used controls in the DevExpress WinForms library since it resembles the default ComoboBox control provided in the default .Net Toolbox. As compared to a normal Combobox control, you can display rows of data in a LookupEdit Control. The control by default supports the AutoComplete feature so when you start typing on the control, the best matches are shown. A sample LookupEdit control in action is shown below.
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 article will explain how we can disable MouseScrolling on the LookupEdit control.
To disable mouse scrolling in the 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 see an example. We have a LookupEdit control on the form and its name is tbEdit.
Write the following code in your Form_Load() and then write the MouseWheel() event handler as in the following.
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(ByVal sender As Object, ByVal 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.
Hope you like this article. Please let me know your thoughts via comments.