|
-
Nov 8th, 2002, 10:20 AM
#1
Thread Starter
Member
call a procedure of a form from the toolbox
i want to use the same buttons (help, save, delete, ...) in the whole mdi-application. Depending on the form which is loaded the buttons have different functions.
Private Sub ToolBar1_ButtonClick(...) Handles ToolBar1.ButtonClick
Dim f As New Form2()
f.F1()
End Sub
F1 is a procedure of Form2... the question is: how can i call the procedure F1 of the Form which is currently loaded?
Dim f As New ???
thank you
-
Nov 8th, 2002, 11:08 AM
#2
PowerPoster
Not exactly following you, but the MDI does have a property called ActiveForm, which returna an object rererence to the form that has focus.
-
Nov 9th, 2002, 01:52 PM
#3
Thread Starter
Member
thanks for your answer...
but the problem is that there are always more than one form loaded and so it is possible that the active-form of the mdi-form is not the form which contains the procedure.
i haven't testet but maybe this works:
Public Class myForm
Inherits System.Windows.Forms.Form
Public Overridable Sub mysavebuttonclick()
End Sub
' for each button of the toolbar a overridable sub or function
End Class
Public module myForms
Public activeForm as myForm
end module
in every form replace
inherits windows.forms.form
with
inherits myForm
and
Protected Overrides Sub OnLoad(...)
myForms.activeForm = me
End Sub
the buttonclickevent calls
myForms.activeForm.mySaveButtonClick
maybe the problem can also be solved with delegates...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|