Reputation: 151
I'm using Visual Basic 2010 Express. When I add a NumericUpDown control to a form, the properties listing for events is not showing a MouseMove event. I know that it exists and I can use AddHandler to create a working handler for it, but it just doesn't show up. It doesn't it show up in the intellisense listing either.
Is there a way to "refresh" the Visual Studio so that it's included?
Upvotes: 1
Views: 665
Reputation: 1563
You have to know that even if you set MouseMove
and MouseLeave
events to NumericUpDown
control, they are will not working properly. And if you really want to handle NumericUpDown
's text box mouse events, you should set it to a second element of NumericUpDown
's Controls
collection (it'll be TextBox
part).
Like this (C# syntax):
myNumericUpDown->Controls[1]->MouseLeave += gcnew System::EventHandler(this, &Form1::myNumericUpDown_MouseLeave);
myNumericUpDown->Controls[1]->MouseMove += gcnew System::Windows::Forms::MouseEventHandler(this, &Form1::myNumericUpDown_MouseMove);
Upvotes: 0
Reputation: 81610
From the source code of the UpDownBase control from which it inherits from:
[EditorBrowsable(EditorBrowsableState.Never)]
[Browsable(false)]
public new event MouseEventHandler MouseMove
Microsoft decided not to make it public. The reason being, I would guess, is that it just doesn't make sense to do anything with a MouseMove event on that control. It is a composite control comprised of a TextBox and some buttons.
If exposing that event is important, you would have to inherit from the NumericUpDown control and expose the event yourself:
public class MyUpDown : NumericUpDown {
[Browsable(true)]
[EditorBrowsable(EditorBrowsableState.Always)]
public new event MouseEventHandler MouseMove {
add { base.MouseMove += value; }
remove { base.MouseMove -= value; }
}
}
And the VB.Net version:
Public Class MyUpDown
Inherits NumericUpDown
<Browsable(True)> _
<EditorBrowsable(EditorBrowsableState.Always)> _
Public Shadows Event MouseMove(sender As Object, e As MouseEventArgs)
Protected Overrides Sub OnMouseMove(e As MouseEventArgs)
MyBase.OnMouseMove(e)
RaiseEvent MouseMove(Me, e)
End Sub
End Class
Upvotes: 1