How to mimic JavaScript's onBlur event in Windows Forms?

前端 未结 4 584
再見小時候
再見小時候 2021-01-18 00:06

I have phone and email textboxes on a Windows Form that I want to validate when the user leaves the fields.

When I double click the textbox in Visual Studio form des

相关标签:
4条回答
  • 2021-01-18 00:32

    Try the Leave event. Navigate to the Property page for your control.

    You can simply type the name of the method you'll be creating. Press Enter and Visual Studio will create the method for you.

    enter image description here

    enter image description here

    0 讨论(0)
  • 2021-01-18 00:38

    OnLostFocus, maybe?

    0 讨论(0)
  • 2021-01-18 00:47

    The Validating event was designed to do this. Set e.Cancel = true if you're not happy with the input. The ErrorProvider component is ideal to provide visual feedback.

    0 讨论(0)
  • 2021-01-18 00:48

    There's an OnLostFocus event for controls. You should be able to use that.

    0 讨论(0)
提交回复
热议问题