order of event

hi, what would be the events order in this situation?

i click on a button>

ok the button.click is triggered

i want to be able to obtain what was the grid that had focus last, and execute its save method, it should be the grid , not the form since a form may contain multiple grids.

i also have a dgv_lostfocus where i set mysave to nothing. i should be able to allow mysave.click to occur and then set mysave to nothing.

clicking on mysave already loses the focus on the dgv, setting it to null.. how do i act here?

[558 byte] By [hrubesh] at [2007-12-24]
# 1

okay i got the flow but:

Private Sub mySave_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles mySave.Click

MsgBox("What is clicking?" & mynavigator.BindingSource.DataMember.ToString)

End Sub

Private Sub DGV_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.LostFocus

mySave = Nothing

End Sub

Public Class myAmountTypesManager

Private WithEvents mysave As New ToolStripButton

Private Sub saveBtn(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mysave.Click

Me.Validate()

DataAccess.SaveSource(Me.AmountTypesBindingSource, _

Me.CostingDataSet.AmountTypes, Me.AmountTypesTableAdapter)

End Sub

so when i click , it executes this one savebtn in myamounttypesmanager and then mySave_Click in the dgv too where i could do something , but even though the lost focus in the dgv,. all forms click are occuring as if the lostfocus didnt work.!

hrubesh at 2007-8-31 > top of Msdn Tech,Windows Forms,Windows Forms Data Controls and Databinding...
# 2

wait what is happening here.

a points to b.

b point to c.

dim c as new button

dim b as button = c

dim a as button = b

a gets the adress of c?

if i go b = nothing., a still referencing c?

hrubesh at 2007-8-31 > top of Msdn Tech,Windows Forms,Windows Forms Data Controls and Databinding...
# 3

irony

'Private Sub AmountTypesDGV_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles AmountTypesDGV.LostFocus

' Me.mysave = Nothing

'End Sub

Private Sub DGV_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.LostFocus

Me.mysave = Nothing

End Sub

both are fired . only with the one thats on the form really set mysave to nothing. thats my whole point of doing all this,. i want my dgv to do 99% of i can do through it,,.. why do i needing to rewrite code on each form . and they seem to both occur.! the mysave on the form references the mysave on the dgv. !

hrubesh at 2007-8-31 > top of Msdn Tech,Windows Forms,Windows Forms Data Controls and Databinding...