The RadToolStrip control supports CausesValidation for when I want my controls validated before a button is pressed, however I can't figure out a way of getting RadRibbonBar to do the same thing. The property CausesValidation exists and I can set it to True, however I don't seem to get the expected Validate event on my editing control. Do I need to set this directly on the RadToolStripElement - and if so, how ?
Thanks,
Phillip
7 Answers, 1 is accepted
You are right -- these RibbonBar events do not fire correctly. We need to investigate the issue. Is it possible to use the events GotFocus, LostFocus in your case as a workaround? Is it also possible not to set CausesValidation to RadToolStripElement -- it is a control level property. Thank you for your detailed feedback.
All the best,
Peter
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Unfortunately Focus and Leave events do not get fired for pushbuttons if the user directly mouse clicks on them, or uses a shortcut key. Generally speaking users don't want focus moving to a toolbar button. Microsoft introduced the CausesValidation property of buttons and toolbars specifically to solve this problem.
Since the CausesValidation property on RadToolStrip works, is there any way I can access the ToolStrip embedded in the Ribbon Bar to set its CausesValidation property directly ?
RadRibbonBar uses self implementation of toolstrip like functionality with many extended features (like collapsing).
We will try to provide a fix in some of the upcoming releases. Please, excuse us for the inconvenience. Don't hesitate to contact us if you have other questions.
Best wishes,
Peter
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
My workaround looks like this, inside the button click event of any ribbon bar button. ("this" is the host Form)
i(! this.ValidateChildren()) return;
However, this shows another problem (raised in another forum post) that RadDock (Q2 2009) is not a ContainerControl - it does not SetStyle(ControlStyles.ContainerControl) so Windows cannot cascade the Validation events through to any controls contained in a RadDock, so it is neccessary to do this as well;
if(! ((ContainerControl)this.radDock.ActiveWindow).ValidateChildren()) return;
It is important to make sure any RadDock implementations in your code implement the Validating event handler and call the above line in that event handler, otherwise the ValidateChildren .net function will be blocked at the RadDock control and won't be able to validate any controls contained in the RadDock.
Thank you very much for sharing the solution. Again, we will do our best to fix this problem in our next release.
Sincerely yours,
Peter
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Try this:
Add an ErrorPovider control to your form to validate that a value entered in a textbox is numeric. If not, display an error like this:
ErrorProvider1.SetError(textbox1, "")
The click the "X" on the form.
You should be able to exit the form without first correcting the error.
RadRibbonBar has the CausesValidation property and when you leave this control, you will get the Validated fired when you leave the RadRibbonBar control. Our suite does not provide validation at the level of the RadElements contained in a RadControls. Phillip's solution is correct in the case where you want to validate the control when you leave it.
The ErrorProvider solution also concerns controls. However, if you do not find Phillip's solution appropriate for your case, you can use the one that you have found.
I hope this helps.
Greetings,
Nikolay
the Telerik team