Using Functions across forms
-
Here is my scenario I have a Main Form and that form has 3 Menus for each menu item I have a dialogbox (another form really) in the main form I have the following sub 'To be called by a docking form (during its activation). Public Sub SetCurrentDialog(dlg As Form) m_curr_dlg = dlg End Sub for each of the menus I have the following Private Sub Menu1_ItemClick(sender As Object, e As ItemClickEventArgs) Handles Menu1.ItemClick SetCurrentDialog(Dilaog1) Dialog1.ShowDialog(Me) End Sub Private Sub Menu2_ItemClick(sender As Object, e As ItemClickEventArgs) Handles Menu2.ItemClick SetCurrentDialog(Dilaog2) Dialog2.ShowDialog(Me) End Sub Private Sub Menu3_ItemClick(sender As Object, e As ItemClickEventArgs) Handles Menu3.ItemClick SetCurrentDialog(Dilaog3) Dialog3.ShowDialog(Me) End Sub in each of the Dialogs I have a Public Function as Public Function ClientMouseUp() 'Do special MouseUp End Function on the MianForm I also have a PicturBox which I want to return information to the dialog so I have Private Sub PictureBox1_MouseUp(sender As Object, e As MouseEventArgs) Handles PictureBox1.MouseUp m_curr_dlg.ClientMouseUp() End Sub But in the PictureBox1_MouseUp I get the following error Error 39 'ClientMouseUp' is not a member of 'System.Windows.Forms.Form'. Can anyone show me the errors of my ways?
-
Here is my scenario I have a Main Form and that form has 3 Menus for each menu item I have a dialogbox (another form really) in the main form I have the following sub 'To be called by a docking form (during its activation). Public Sub SetCurrentDialog(dlg As Form) m_curr_dlg = dlg End Sub for each of the menus I have the following Private Sub Menu1_ItemClick(sender As Object, e As ItemClickEventArgs) Handles Menu1.ItemClick SetCurrentDialog(Dilaog1) Dialog1.ShowDialog(Me) End Sub Private Sub Menu2_ItemClick(sender As Object, e As ItemClickEventArgs) Handles Menu2.ItemClick SetCurrentDialog(Dilaog2) Dialog2.ShowDialog(Me) End Sub Private Sub Menu3_ItemClick(sender As Object, e As ItemClickEventArgs) Handles Menu3.ItemClick SetCurrentDialog(Dilaog3) Dialog3.ShowDialog(Me) End Sub in each of the Dialogs I have a Public Function as Public Function ClientMouseUp() 'Do special MouseUp End Function on the MianForm I also have a PicturBox which I want to return information to the dialog so I have Private Sub PictureBox1_MouseUp(sender As Object, e As MouseEventArgs) Handles PictureBox1.MouseUp m_curr_dlg.ClientMouseUp() End Sub But in the PictureBox1_MouseUp I get the following error Error 39 'ClientMouseUp' is not a member of 'System.Windows.Forms.Form'. Can anyone show me the errors of my ways?
typo?
SetCurrentDialog(Dilaog1)
or
SetCurrentDialog(Dialog1)
-
typo?
SetCurrentDialog(Dilaog1)
or
SetCurrentDialog(Dialog1)
-
Here is my scenario I have a Main Form and that form has 3 Menus for each menu item I have a dialogbox (another form really) in the main form I have the following sub 'To be called by a docking form (during its activation). Public Sub SetCurrentDialog(dlg As Form) m_curr_dlg = dlg End Sub for each of the menus I have the following Private Sub Menu1_ItemClick(sender As Object, e As ItemClickEventArgs) Handles Menu1.ItemClick SetCurrentDialog(Dilaog1) Dialog1.ShowDialog(Me) End Sub Private Sub Menu2_ItemClick(sender As Object, e As ItemClickEventArgs) Handles Menu2.ItemClick SetCurrentDialog(Dilaog2) Dialog2.ShowDialog(Me) End Sub Private Sub Menu3_ItemClick(sender As Object, e As ItemClickEventArgs) Handles Menu3.ItemClick SetCurrentDialog(Dilaog3) Dialog3.ShowDialog(Me) End Sub in each of the Dialogs I have a Public Function as Public Function ClientMouseUp() 'Do special MouseUp End Function on the MianForm I also have a PicturBox which I want to return information to the dialog so I have Private Sub PictureBox1_MouseUp(sender As Object, e As MouseEventArgs) Handles PictureBox1.MouseUp m_curr_dlg.ClientMouseUp() End Sub But in the PictureBox1_MouseUp I get the following error Error 39 'ClientMouseUp' is not a member of 'System.Windows.Forms.Form'. Can anyone show me the errors of my ways?
You need an Interface with the function ClientMouseUp, and all of your dialogs need to implement it.
-
You need an Interface with the function ClientMouseUp, and all of your dialogs need to implement it.