4 Answers, 1 is accepted
Thank you for writing.
You can subscribe to the Click event of the RadMaskedEditBox using the following code:
this
.radMaskedEditBox1.MaskedEditBoxElement.TextBoxItem.Click +=
new
EventHandler(MaskedEditBoxElement_Click);
I hope this will help you. If you have further questions, I would be glad to help. All the best,
Ivan Petrov
the Telerik team
Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

I apologize for being vague and unclear. I need to assign the MouseClick event because I'm trying to capture a right mouse click on all labels, buttons, dropdownlists, and maskedEditBoxes. I'm able to use this with buttons, dropdownlists, and labels, but not the masked edit box.
If you consider the following code, There isn't MouseClick event for this.radMaskedEditBox1.MaskedEditBoxElement.TextBoxItem so I've tried using the MouseUp event. However that fails with the following invalid cast type exception: "Unable to cast object of type 'Telerik.WinControls.UI.RadTextBoxItem' to type System.Windows.Forms.Control'."
Now using this.radMaskedEditBox1.MouseClick will work, however the user has to click on the small border line to fire the event and isn't the desired action.
Lastly, I've tried this.radMaskedEditBox1.MaskedEditBoxElement.TextBoxItem.HostedControl.MouseClick, however left mouse clicks will fire the event, but not right.
This should be more helpful to the issue at hand.
private
void
Form1_Load(
object
sender, EventArgs e)
{
//Runtime Error: Invalid Cast
this
.radMaskedEditBox1.MaskedEditBoxElement.TextBoxItem.MouseUp +=
new
MouseEventHandler(MouseClick);
//Closest to working, but doesn't fire with right mouse click
this
.radMaskedEditBox1.MaskedEditBoxElement.TextBoxItem.HostedControl.MouseClick +=
new
MouseEventHandler(MouseClick);
//Doesn't fire on the textbox, only the border
this
.radMaskedEditBox1.MouseClick +=
new
MouseEventHandler(MouseClick);
//Works perfectly
this
.radLabel1.MouseClick +=
new
MouseEventHandler(MouseClick);
}
private
void
MouseClick(
object
sender, MouseEventArgs e)
{
Control c = (Control)sender;
this
.radLabel1.Text =
"Clicked On "
+ c.GetType() +
" using a "
+ (e.Button == MouseButtons.Right ?
"Right Click"
:
"Left Click"
);
}
Bret

this
.radMaskedEditBox1.MaskedEditBoxElement.TextBoxItem.HostedControl.MouseUp +=
new
MouseEventHandler(MouseClick);
Seems to work.
~Bret
I am glad you have found your way in this.
I am writing to confirm that this is the right approach and solution for your scenario.
I have marked your post as an answer, so others can use it.
Should you have further questions I would be glad to answer them.
Ivan Petrov
the Telerik team
Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>