firing an event on close

  • Thread starter Thread starter Shannon Ramirez
  • Start date Start date
S

Shannon Ramirez

I would like options on what approach woudl be best.

There is a form1 that has a datagrid. When a row on the datagrid is
double clicked, it opens form2 with some info. Form2 allows editing
and has an update button. When the update button is clicked, I like
for the form to close and fire an event that will rebind the data to
the grid so update information is show.

What is the best approach for this and can someone give me a little
code example.. nothing to complicated.. just need a direction. I'm a
vb newbie..

thanks
shannon
 
I think the best approach is to open form2 as a dialog with
frm2.ShowDialog.

This creates a modal form that has to be closed before the user can
continue. On form2 set the cancel button to have a dialog result of
Cancel and the Update button to a dialog result of Yes. You do this in
the property inspector

Then in frm1 you would go somthing like this

Sub OnDoubleClick()

dim frm2 as new form2

try
if frm2.dialogresult = dialogresult.Yes then
' Update your datagrid
End If
catch
finally
if not frm2 is nothing then frm2.dispose
end try

End Sub

hth

Richard
 
Oh and obviously its up to you to feed frm2 the UserId or whatever
your after so you can extract the record from the Datasource and
populate the form.

Just pass the id into the constructor of your form2

dim frm2 as new form2(UserId)

.... etc etc

Richard
 
Back
Top