Hi,
I have a form with multiple numeric editors and an ultratoolbar. I have an afterexiteditmode event that fires to convert the value from a whole number to a decimal (processing percent values that have a P format).
When I click on the toolbar button the numeric editor does not lose focus, it stays in edit mode. I can test if the control is in edit mode on the toolclick event of the toolbar however I can't get the numeric editor to fire that exit mode event.
So far this only seems to happen when I click on a toolstripbutton. The textbox and other types of controls let the numeric editor lose focus.
How do I get around this?
Thanks,
M.
Hello,
Thank you for contacting Infragistics Support.
By design the tools in toolbar cannot get focus. This is why when you click on the toolstripbutton your editor does not lose the focus.
As a work around I could suggest you in your toolstripbutton click event setting the focus to the toolbar where the toolstripbutton is positioned.
Please find attached a sample solution implementing this approach.
Please let me know if this is what you are looking for or if I am missing something.
Thanks. I am going to check and your example and let you know.
The example is using a windows toolstrip. I am using an ultratoolbar. Your toolbars do not have a 'foucus' or select method.
The Toolstrip and the UltraToolbarsManager are both toolbars and so neither one takes focus. This is, of course, intentional. Many toolbar buttons require some context of some other control. For example, Cut, Copy, and Paste. These would be impossible to implement if the toolbar took focus away from the active control on the form, because you would not have any way to know the control to which the operation is applied.
As for a LostFocus, there's no method that will force this to happen, other than setting focus to some other control. Why do you want the control to lose focus or leave edit mode? I'm assuming that you probably want the contents of the control to be validated before you perform some operation like a Save.
So what you probably need to do is call the ValidateChildren method on the form.
Thanks. You gave me another idea to see if the control is in edit mode.
if (!uneTaxRate.IsInEditMode)
We have a number of forms that allow editing a tax rate and saving. So we are using the after exit to convert the value from a whole # to a decimal # since we are using the 'P' format.
So in the numeric editor when you use P as the format string it is very nice because it converts the number from a fraction (like .02) into a whole # percent (2%). However when you click in the control to edit it shows the fraction (.02) and for the everyday person that might be confusing. So we use the before and after edit events to convert the #.
A lot of times though they go right for the 'update' button on the toolbar. I think though in retrospect we should move this type of checking to a validation.
Thanks for the help.