Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
910
Validating event on tool click
posted

Hi,

I have a custom control on a form with textfields, where I do some validation by subscribing to the "textbox_validating" event.

But when I click on a tool item from the toolbarmanager (hosted in the form), the validating event of the textbox is not fired.

Thanks for help to understand this behaviour,

Michael

Parents
  • 4625
    Offline posted

    Hi Michael,

    Thank you for posting in our forums!

    In order to raise validating event of any control subscribed to it, you must either move its focus to another control or force it explicitly to be raised. As far as I understand you have a scenario where on clicking ToolbarsManager’s tool, custom control’s textbox validation should be raised.

    All Windows Forms control containers implement two methods that force validating of one or all children controls. These methods are Validate and ValidateChildren. For further reference see MSDN’s documentation pages:

    https://msdn.microsoft.com/en-us/library/4wf8t2at(v=vs.110).aspx

    https://msdn.microsoft.com/en-us/library/ms158375(v=vs.110).aspx

    Therefore you have to subscribe to ToolbarsManager ToolClick’s event and invoke custom control’s Validate method. This is going to raise the validating event only on the last control (text box) that was on focus.

    Please let me know if you have any additional questions.

    ToolbarsManagerTextBoxValidation.zip
Reply Children