Please can any one advise if there is a way for the RadMessageBox to be set up so when Yes / No buttons are used, pressing "Y" or "N" on the keyboard will trigger the buttons?
We are using 2009 Q2 controls.
Thanks and kind regards,
8 Answers, 1 is accepted
I don't have access to this version of the controls, but I think this should work (I am using the latest version).
This is based on setting up a global shortcut on the form, checking to see if the focused control's parent is a RadMessageBox and then setting the dialog result to the chosen value.
You can find out more about global shortcuts at this help topic
So, to implement this...
1: Desfine a shortcut provider that checks for Crtrl+Y and Ctrl+N and if it gets either of these, then as long as the FocusedControl parent is a RadMessageBox, it will send the response.
2: In your form, create a class level field to hold the shortcut provider
3: Set up the shortcuts
4: On a button press (for example) launch the RadMessageBox to test
I hope that helps but let me know if you have any questions
Thanks for that. It does seem a little long winded having to set that up and then assign the use for EVERY form (providing I have understood correctly!) As we have over 500 forms in our application so it will be a bit of a bind to implement. I'm sure before we changed over to the Telerik controls, the standard MS .Net dialogs worked off the shelf with "Y" and "N" key presses triggering the dialog's buttons.
I'll will look at implementing your solution though. Thanks again.
Yes, you have understood correctly and it is quite long. Perhaps that would be a good feature request to submit to Telerik.
Let me know if you have further questions
@Richard: Thank you for your assistance.
@Duane: You can also achieve this behavior by setting a custom localization provider that will be used by all message boxes. You can use the following code snippet:
Then you should replace the default localization provider when your application is started:
Finally, you can show the message box anywhere in your application:
the Telerik team
Hi Svett, That is brilliant and just what I need. A fair bit easier to implement than Richard example. Implmented and working.
@Richard: Sorry had to go with Svett's example as easier to implement in such a large project. Thanks for your input though.
Edited for spellos!
All the best
I implemented your solution and now the RadMessageBox shows the shortcut underline for "Y" in Yes, however, pressing the "Y" does not provide any action. Is there something I'm doing wrong?
Thank you for writing.
Your question has already been answered in the support thread you have opened on the same topic. However, I am posting the answer here as well in order the community to benefit from it.
In order to achieve your goal, you need to use RadShortcut. Here is a sample code snippet:
I hope this information helps. Should you have further questions, I would be glad to help.
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.