Reputation: 744
Frist of all sorry for my bad english.
I'm making an application in VB.NET and I have a little problem. I have two forms one main FORM (always open), and one that I open as Dialog.
In the secondary form (such as the open dialog) I can choose what to do and based on what I choose I have to trigger an event in the main form. Let me explain, In the child form I choose the customer number 2, I press OK, and the main form has to load all the data related to the customer number 2.
Obviously, being object-oriented vb.net I can not call a sub from another form (because I do not have access to the instance) and I can not declare a new one, because the main form is always open.
How do I then pass the id of the customer and raise the event to load?
Upvotes: 3
Views: 13464
Reputation:
Expose the customer ID in the child through a Public or Friend property, for example (child form):
Public Property CustomerID as Integer
Private Sub OK_Click(s as Object, e as eventargs) Handles OK.Click
CustomerID = id 'pass the value here
Me.DialogResult = DialogResult.Ok
End Sub
On the main form then:
If frmChild.ShowDialog = DialogResult.Ok Then
MessageBox.Show("Customer ID: " + frmChild.CustomerID)
End If
Upvotes: 7