This is a migrated thread and some comments may be shown as answers.

CausesValidation and RibbonBar

7 Answers 104 Views
RibbonBar
This is a migrated thread and some comments may be shown as answers.
Phillip
Top achievements
Rank 1
Phillip asked on 10 Aug 2009, 03:13 PM
Hi,

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

Sort by
0
Peter
Telerik team
answered on 11 Aug 2009, 11:59 AM
Hi Phillip,

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.
0
Phillip
Top achievements
Rank 1
answered on 11 Aug 2009, 01:16 PM
Hi Peter,

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 ?
0
Accepted
Peter
Telerik team
answered on 13 Aug 2009, 08:27 AM
Hi Phillip,

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.
0
Phillip
Top achievements
Rank 1
answered on 13 Aug 2009, 02:23 PM

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.

 

 

 

 

 

 

0
Peter
Telerik team
answered on 17 Aug 2009, 07:22 AM
Hi Phillip,

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.
0
Chad
Top achievements
Rank 2
answered on 11 Dec 2010, 12:25 AM
This is no solution!  Do I understand correctly, thgere is no "CausesValidation" property on a RadButtonElement?!

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.




0
Nikolay
Telerik team
answered on 15 Dec 2010, 12:13 PM
Hi Chad,
 
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
Get started with RadControls for WinForms with numerous videos and detailed documentation.
Tags
RibbonBar
Asked by
Phillip
Top achievements
Rank 1
Answers by
Peter
Telerik team
Phillip
Top achievements
Rank 1
Chad
Top achievements
Rank 2
Nikolay
Telerik team
Share this question
or