Am I going mad
I have a form with a bindingNavigator bar and a bunch of text box controls. It appears that Click events on the bindingNavigator buttons fire before the control that loses focus fires the Leave and LostFocus events
Is this behaviour by accident or design or am I doing something wrong

Windows Forms Problem
susqu
joebrown
From the form:
Private Sub bindingNavigatorMoveNextItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles bindingNavigatorMoveNextItem.Click If IsDirtyRecordOK(Me.ClacksonsLocationsBindingSource, IsNewRecord, IsDirty) Then
Exit Sub
Else
Me.ClacksonsLocationsBindingSource.MoveNext()
Me.ClacksonsLocationsBindingSource.ResetBindings(False)
End If
End Sub
Private Sub LocationAddress1TextBox_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles LocationAddress1TextBox.Leave
FormatProperString(LocationAddress1TextBox)
If Me.LocationAddress1TextBox.Modified Then
IsDirty = True
End If
End Sub
From a separate module:
Public Function IsDirtyRecordOK(ByVal InputBindingSource As Windows.Forms.BindingSource, ByVal IsNewRecord As Boolean, ByRef IsDirty As Boolean) As Boolean 'This function checks what the user wants to do with a dirty record and returns true if
'no further action is required (ie cancel changes) Dim MsgBoxReply As MsgBoxResult
If Not IsDirty Then Return True
MsgBoxReply = MsgBox("There are outstanding changes to the record" & vbCrLf & "Do you want the opportunity to save the record ", MsgBoxStyle.Question + MsgBoxStyle.YesNo, "Record Changes Pending")
If MsgBoxReply = MsgBoxResult.Yes Then
Return False
Else
InputBindingSource.CancelEdit()
IsDirty = False
Return True
End If
End Function
Thanks for your interest in my problem
CKdp
The order of events posted is fro entering and leaving the same control...
I would suggest moving your code to the validating event.
MSDevPartners
Public Function FormatProperString(ByRef StringBox As TextBox) As Boolean
'This function examines a text string and formats the string into '"proper" format if the string is all upper case or lower case. Mixed
'case strings remain unchanged. The function returns true if the text
'string has been reformated otherwise it returns false Dim InString As String
Dim ix As Integer
Dim UpperCase, LowerCase As Boolean
InString = Trim(StringBox.Text)
UpperCase = False
LowerCase = False
For ix = 0 To Len(InString) - 1
If Char.IsLetter(InString, ix) Then
LowerCase = LowerCase And Char.IsLower(InString, ix)
UpperCase = UpperCase And Char.IsUpper(InString, ix)
End If
'Bale out if we have a mixed case string
If UpperCase And LowerCase Then Return False
Next
StringBox.Text = StrConv(InString, VbStrConv.ProperCase)
Return True
End Function
For the avoidance of doubt, can you can confirm that the event order is more explicitly:
If I am right, then I would have to go back and programatically check to see if the data in the control had changed unless there is a simpler way to achieve the same aim
Do all these event occur in the same thread or is there a way of identifying when the Leave event has been completed
Aaron West
2. take a look here:ms-help://MS.VSCC.2003/MS.MSDNQTR.2005JAN.1033/cpref/html/frlrfSystemWindowsFormsControlClassLeaveTopic.htm
Remarks
When you change the focus by using the keyboard (TAB, SHIFT+TAB, and so on), by calling the Select or SelectNextControl methods, or by setting the ContainerControl.ActiveControl property to the current form, focus events occur in the following order:
When you change the focus by using the mouse or by calling the Focus method, focus events occur in the following order:
If the CausesValidation property is set to false, the Validating and Validated events are suppressed.
For more information about handling events, see < XML:NAMESPACE PREFIX = MSHelp NS = "http://msdn.microsoft.com/mshelp" />Consuming Events .