I've dynamically added a RadSpinElement to my RadRibbonBar and I'd like to make it so that the MouseWheel scrolling does not affect the value in the textbox. I'd like the user to have to either hold down the up/down arrow or type in a value.
Is there an event or property I can use to achieve this?
Is there an event or property I can use to achieve this?
3 Answers, 1 is accepted
0
Accepted
Hi Jason,
Thank you for writing.
You should set the RadSpinElement EnableMouseWheel property that gets or sets a value indicating whether the user can change the value with mouse wheel.
I hope this helps.
Kind regards,
Peter
the Telerik team
Thank you for writing.
You should set the RadSpinElement EnableMouseWheel property that gets or sets a value indicating whether the user can change the value with mouse wheel.
I hope this helps.
Kind regards,
Peter
the Telerik team
You’ve been asking for it and now it’s time for us to deliver. RadControls for WinForms Q3 2012 release is just around the corner. Sign up for a free webinar to see first all the latest enhancements.
0
Jason
Top achievements
Rank 1
answered on 11 Oct 2012, 04:57 PM
Is that property new in the 2012 Q2 release? I'm using the Q1 release and I don't see that property available - however I do see it in the online documentation.
0
Hi Jason,
The property will be available in the next major release, which will be available by the end of the next week. Nevertheless, you can create a custom editor to achieve the desired scenario. You can use the following code snippet:
Then you should use the EditorRequired event to replace the default one:
Regards,
Svett
the Telerik team
The property will be available in the next major release, which will be available by the end of the next week. Nevertheless, you can create a custom editor to achieve the desired scenario. You can use the following code snippet:
public
class
MyGridSpinEditorElement : GridSpinEditorElement
{
private
static
readonly
MethodInfo MouseWheelMethodInfo;
static
MyGridSpinEditorElement()
{
MouseWheelMethodInfo =
typeof
(RadSpinElement).GetMethod(
"textItem_MouseWheel"
, BindingFlags.Instance | BindingFlags.NonPublic);
}
private
MouseEventHandler SpinElementMouseWheel;
private
bool
enableMouseWheel =
true
;
public
MyGridSpinEditorElement()
{
}
protected
override
void
WireEvents()
{
base
.WireEvents();
if
(
this
.SpinElementMouseWheel ==
null
)
{
this
.SpinElementMouseWheel = Delegate.CreateDelegate(
typeof
(MouseEventHandler),
this
, MouseWheelMethodInfo)
as
MouseEventHandler;
}
this
.TextBoxItem.MouseWheel -=
this
.SpinElementMouseWheel;
this
.TextBoxItem.HostedControl.MouseWheel -=
this
.SpinElementMouseWheel;
this
.TextBoxItem.MouseWheel +=
new
MouseEventHandler(TextBoxItem_MouseWheel);
this
.TextBoxItem.HostedControl.MouseWheel +=
new
MouseEventHandler(TextBoxItem_MouseWheel);
}
protected
override
void
UnwireEvents()
{
base
.UnwireEvents();
this
.TextBoxItem.MouseWheel -=
new
MouseEventHandler(TextBoxItem_MouseWheel);
this
.TextBoxItem.HostedControl.MouseWheel -=
new
MouseEventHandler(TextBoxItem_MouseWheel);
}
public
bool
EnableMouseWheel
{
get
{
return
this
.enableMouseWheel; }
set
{
this
.enableMouseWheel = value; }
}
private
void
TextBoxItem_MouseWheel(
object
sender, MouseEventArgs e)
{
if
(
this
.enableMouseWheel)
{
this
.SpinElementMouseWheel(sender, e);
}
}
}
public
class
MyGridSpinEditor : GridSpinEditor
{
protected
override
Telerik.WinControls.RadElement CreateEditorElement()
{
MyGridSpinEditorElement element =
new
MyGridSpinEditorElement();
element.EnableMouseWheel =
false
;
return
element;
}
}
Then you should use the EditorRequired event to replace the default one:
void
radGridView1_EditorRequired(
object
sender, EditorRequiredEventArgs e)
{
if
(e.EditorType ==
typeof
(GridSpinEditor))
{
e.EditorType =
typeof
(MyGridSpinEditor);
}
}
Svett
the Telerik team
You’ve been asking for it and now it’s time for us to deliver. RadControls for WinForms Q3 2012 release is just around the corner. Sign up for a free webinar to see first all the latest enhancements.