Notice that in the previously described scenario – the end user moves the focus away with the mouse but the control fails to validate – then a pair of Lost Focus/Got Focus events is fired anyway (unlike VB6), but this is seldom a problem. Run(form1) End Sub End Class Public Class Form1 Inherits System. Protected Overloads Overrides Sub Dispose(By Val disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components. Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System. IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. VB6 controls fire the Validate event first and then the Lost Focus event; if the Validate sets Cancel=True, then the Lost Focus event is never fired.The sequence is the same regardless of how the end user moves the input focus away from the control. NET controls fire these events in the same sequence only if end users move the input focus by means of the keyword; if they use the mouse, the control fires a Lost Focus event, then the Validating event, and – if the validation fails – another Got Focus event to let the application know that the focus is again on the control. NET programs created by VB Migration Partner follow the . In most cases, the fact that the Lost Focus event fires before the Validate event doesn’t affect the application negatively.thx and regard,s Norton Norton, I got the following tip from "Windows Forms Programming in C#" by Chris Sells, from Addison Wesley. How can something be wrong in a textbox when you use correct the validating event.Within your "Accept" button click handler (the "save" button) process each control that Causes Validation to ensure that they are all valid... (Assuming you are not placing conflicting date in there by the program) It will be executed as that control looses the focus. Cor Phill, Now I understood you, in fact do you want to check if they are not empty?Click Here to read that article and then return to this one. For example, this might come in handy if you had a two stage validation. A call to Validate can be triggered by code elsewhere, but it still doesn't trigger the Validating and Validated events as shown below.--------Click Here to display the illustration--------The second is to call Validate from a container control where the controls that you want validated are child controls.
Back Color = vb Yellow End Sub Private Sub Text1_Lost Focus() Text1.The first Quick Tip Validation Guide defined validation as "the process of checking whether entered data is what it needs to be for the system to work correctly." And I noted in that article that: Windows form controls that have a Causes Validation property can fire a whole family of events when the focus shifts from the control.Microsoft calls this "implicit validation" because the events are fired "implicitly" by . Microsoft refers to coding a call to the Validate or Validate Children method as "explicit validation". Writeline is the fastest and easiest way to check whether that actually happens.--------Click Here to display the illustration--------There are two 'explicit' validation methods:-Validate Children Both have two overloads. The Validate Method You might think that you can trigger the execution of the Validating or Validated events by calling Validate from, for example, a Button, but you can't.end sub As alternative for the already supplied options, while not knowing what actions you take because of validationg errors. NET controls is in the order in which they fire the Lost Focus and Validate events.You might even loop through all the controls on your form and focus each of them individually (or an individual control by giving it focus then changing the focus to another control), achieving the same effect: Which solution is better?