-2

Working on building a form with several Databound controls and noticed that can't leave the Datetimepicker or combobox's that are on the form.

        // signoutAfterDateTimePicker
        // 
        this.signoutAfterDateTimePicker.DataBindings.Add(new System.Windows.Forms.Binding("Value", this.clientBindingSource, "SignoutAfter", true));
        this.signoutAfterDateTimePicker.Format = System.Windows.Forms.DateTimePickerFormat.Time;
        this.signoutAfterDateTimePicker.Name = "signoutAfterDateTimePicker";

Since I couldn't find anything on Datetime picker but found a similar issue to Cannot tab out of databound Winforms dropdown list . So posted this link discussing how to fix the drop down list. Thought those with DateTimePicker issues would also find that link useful.

The workaround is to set the CausesValidation to false.

this.signoutAfterDateTimePicker.CausesValidation = false;

Of course you will probably want to actually validate.

3
  • 1
    You should phrase this into a question. That makes it easier for people searching to arrive at the answer faster. Simply linking to another question with no context makes it more difficult. (That question could be deleted or changed, for example). Aug 10, 2012 at 19:50
  • We prefer more substantial questions and answers if you're going to do the self answer thing. Thanks.
    – Kev
    Aug 10, 2012 at 23:16
  • Edited question to make it more substantial.
    – Brian Hanf
    Aug 22, 2012 at 16:26

1 Answer 1

2

Answer is to set CausesValidation to False - just like the above link suggests.

1
  • OMG you save my life this is work like a charm any side effect from setting CausesValidation to False ? Jun 24, 2016 at 6:46

Not the answer you're looking for? Browse other questions tagged or ask your own question.