I am working application written in C# and I want simple event handling code.
I have two forms, One form contains a simple grid which contain list of customer and one form which have some text boxes and accepts the information of customer which saves data in DB.
Now, I want to use event in this process.
When user save the data using detail form, event should be raised and it will reload all the data in grid(with recently added record)
I have this code which is written in VB.NET, its quite simple but I still unable to understand how to write C# event handling code.
VB Code
Code of Grid form
Private Sub AddCustomer()
AddHandler Detailform.DataAdded, AddressOf AddRow
End sub
Private Sub AddRow()
dt = LoadAllCustomer()
gc.DataSource = dt
gv.FocusedRowHandle = OCustomerCollection.Count - 1
End Sub
Code of customer Details form
'Declaration
Public Event DataAdded()
Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.
SetProperties()
' invoke save
oCustomer.Save()
RaiseEvent DataAdded()
End sub