I have a simple contact book. The application has a main window that's an mdi form. When a contact is added using the "add a contact" form, I want to show a simple feedback message in the parent window status bar saying that the contact was added successfully.
Here's the child loading:
Private Sub addButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles addButton.Click
Dim af As New addForm
af.MdiParent = Me
af.Show()
End Sub
The problem is that since the parent is actually an mdi parent, and the "add a contact" form is launched with .Show()
instead of .ShowDialog()
, I can't store any return value that can be used by the launching Sub to perform an action.
Is there a way to pass a value from this child to the mdi parent? Here's the child form doing it's stuff:
Private Sub addButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles addButton.Click
Dim contact = <contact>
<quickName><%= quickNameTextBox.Text %></quickName>
<firstName><%= firstNameTextBox.Text %></firstName>
<lastName><%= lastNameTextBox.Text %></lastName>
<email><%= emailTextBox.Text %></email>
<website><%= websiteTextBox.Text %></website>
<telephone><%= telephoneTextBox.Text %></telephone>
<mobile><%= mobileTextBox.Text %></mobile>
</contact>
Dim contactList = XDocument.Load("contactList.xml")
contactList.Elements()(0).Add(contact)
contactList.Save("contactList.xml")
//something here to trigger the status update in the parent?
//trivia: SO doesn't support VB single-quote comments...
Me.Close()
End Sub
P.S. Apparently, I'm rather bad at tagging things...so anyone wanting to retag this question are most welcome.