G
Guest
In an SDI application, I'd like to share a single instance of a Search form
across more than one form.
Currently, I'm creating an instance of a Search form from the form (say
Form1, Search button Click event) where I wish to do a Search. Then I'm
subscribing to an event that the Search form will raise when the user selects
a matching record. Like this:
Private Sub btnSearch_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnSearch.Click
m_thisSearch = New SearchForm
AddHandler m_thisSearch.SelectedItem, AddressOf ItemSelected
m_thisSearch.Show()
End Sub
Private Sub ItemSelected(ByVal ItemID As String)
' This procedure gets invoked when a ItemID is selected on the
Search form.
txtItemID.Text = ItemID
End Sub
If the SearchForm is implemented as a Singleton, and the event is subscribed
to by more than one form, all forms will receive the event message. I'd like
to target the result of the search to be directed only to the form from which
the SearchForm was most recently invoked. And the SearchForm may *not* be
Modal.
Any suggestions/ideas/comments are most welcome. Please help.
Thanks.
across more than one form.
Currently, I'm creating an instance of a Search form from the form (say
Form1, Search button Click event) where I wish to do a Search. Then I'm
subscribing to an event that the Search form will raise when the user selects
a matching record. Like this:
Private Sub btnSearch_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnSearch.Click
m_thisSearch = New SearchForm
AddHandler m_thisSearch.SelectedItem, AddressOf ItemSelected
m_thisSearch.Show()
End Sub
Private Sub ItemSelected(ByVal ItemID As String)
' This procedure gets invoked when a ItemID is selected on the
Search form.
txtItemID.Text = ItemID
End Sub
If the SearchForm is implemented as a Singleton, and the event is subscribed
to by more than one form, all forms will receive the event message. I'd like
to target the result of the search to be directed only to the form from which
the SearchForm was most recently invoked. And the SearchForm may *not* be
Modal.
Any suggestions/ideas/comments are most welcome. Please help.
Thanks.