CausesValidation and RibbonBar

8 posts, 1 answers
  1. Phillip
    Phillip avatar
    31 posts
    Member since:
    Apr 2009

    Posted 10 Aug 2009 Link to this post

    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
  2. Peter
    Admin
    Peter avatar
    1148 posts

    Posted 11 Aug 2009 Link to this post

    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.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Phillip
    Phillip avatar
    31 posts
    Member since:
    Apr 2009

    Posted 11 Aug 2009 Link to this post

    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 ?
  5. Answer
    Peter
    Admin
    Peter avatar
    1148 posts

    Posted 13 Aug 2009 Link to this post

    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.
  6. Phillip
    Phillip avatar
    31 posts
    Member since:
    Apr 2009

    Posted 13 Aug 2009 Link to this post

    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.

     

     

     

     

     

     

  7. Peter
    Admin
    Peter avatar
    1148 posts

    Posted 17 Aug 2009 Link to this post

    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.
  8. Chad
    Chad avatar
    2 posts
    Member since:
    Aug 2012

    Posted 10 Dec 2010 Link to this post

    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.




  9. Nikolay
    Admin
    Nikolay avatar
    1803 posts

    Posted 15 Dec 2010 Link to this post

    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.
Back to Top
UI for WinForms is Visual Studio 2017 Ready