Results 1 to 3 of 3

Thread: call a procedure of a form from the toolbox

  1. #1

    Thread Starter
    Member
    Join Date
    Nov 2002
    Location
    Austria
    Posts
    52

    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

  2. #2
    PowerPoster Lethal's Avatar
    Join Date
    Oct 2000
    Location
    Ohio
    Posts
    2,496
    Not exactly following you, but the MDI does have a property called ActiveForm, which returna an object rererence to the form that has focus.

  3. #3

    Thread Starter
    Member
    Join Date
    Nov 2002
    Location
    Austria
    Posts
    52
    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
  •  



Click Here to Expand Forum to Full Width