I have a form called privateOrder, and two other forms.

in the first form when I double click on a datagridview it opens the privateOrder form.

in the second form I have a button, when I click it also calls the privateOrder form.

I want to know if there is a way to distinguish what event calls the

privateOrder.show()

Depending on the event called for PrivateOrder I want the privateOrder_Load Behave in two different situations.

I tried to use the "e" parameter but when privateOrder loads the "e" parameter is empty.

is there any idea?
thanx.

Edited 6 Years Ago by adam84: n/a

Instead of just using form1.show, in the form module you could overload the New method of the form and create a new property indicating who was it called from:

Public Class privateOrder
    Inherits Form

    '...
    '...

    ' Use this property to store who is calling the form
    ' and call it after it is created (in the load event)
    Public ReadOnly CalledFrom As CalledFromV

    Public Enum CalledFromV
        FromDataGrid
        FromButton
    End Enum

    ' ...
    ' ...

    Public Sub New(ByVal From As CalledFromV)
        MyBase.New()

        ' specify when creating the form who is calling it
        CalledFrom = From
    End Sub

    '...
    '...

End Class

the in the moment you create the new form you specify where is it being called from...

Private Sub DataGrid1_DoubleClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) _
        Handles DataGrid1.DoubleClick

        ' ...
        ' ...

        ' After this, when the form loads you'll be able to know who called it
        ' just check the value of its CalledFrom property
        Dim NewOrder As New privateOrder(CalledFromV.FromDataGrid)
        ' if it would have been called from the button you could use:
        'Dim NewOrder As New privateOrder(CalledFromV.FromButton)
        NewOrder.Show()

    End Sub
This question has already been answered. Start a new discussion instead.