Home Forums WinForms controls Other WinForms controls Validation Provider: Allow Focus Change

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #18497 |

    I’ve set a WinTextBox to validate using the ValidationProvider (data type of “Date”) and it seems to work properly, but it won’t allow focus to move off of the control until the validation problem is fixed. 

    How can I allow tabbing off of a control that has a validation issue?

    Thanks. 

     

     

     

    Imported from legacy forums. Posted by Paul (had 2906 views)

    User (Old forums)
    Member
    Post count: 23064

    You need to handle the Validating event on the WinTextBox, and set the Cancel property on the CancelEventArgs to false.

    e.g. :

    private void Form1_Load( object sender, EventArgs e )

    {

        winTextBox1.Validating +=

    new CancelEventHandler( winTextBox1_Validating );

    }

    void winTextBox1_Validating( object sender, CancelEventArgs e )

    {

        e.Cancel = false;

    }

     

    Imported from legacy forums. Posted by André (had 335 views)

    User (Old forums)
    Member
    Post count: 23064

    It would be nice if the behaviour of the ValidationProvider was configurable to allow it to handle a validation error by automatically canceling or not.

    Imported from legacy forums. Posted by Paul (had 3702 views)

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.