how to call a particular event from a previous page in my current page

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gracepaul
    New Member
    • Jul 2008
    • 28

    how to call a particular event from a previous page in my current page

    hi all,


    I want to call the Mouse_Click event from the previous form f1 in the next form f2.
    how can do that?

    when i close the form f2 and then raise the mouse_click event in form f1 at that moment .

    i am using the following code which is written in form f2

    in form f2
    ------------


    this.Close();
    form1 f1=new form1();
    f1.dateNavigato rsch_MouseClick (sender, e)


    The above code raise the following errors as follows



    The best overloaded method match for 'Scheduling.f1. dateNavigatorsc h_MouseClick(ob ject, System.Windows. Forms.MouseEven tArgs)' has some invalid arguments



    Argument '2': cannot convert from 'System.EventAr gs' to 'System.Windows .Forms.MouseEve ntArgs'


    Please reply if anyone have an idea...

    Thanks in advance

    Grace
  • tlhintoq
    Recognized Expert Specialist
    • Mar 2008
    • 3532

    #2
    Code:
    [QUOTE=gracepaul]hi all,
    
    
    I want to call the Mouse_Click event from the previous form f1 in the next form f2.
    how can do that? 
    
    when i close the form f2 and then raise the mouse_click event in form f1 at that moment .
    
    i am using the following code which is written in form f2
    
    in form f2
    ------------
    
    [CODE=c]
    this.Close();
    form1 f1=new form1();
    f1.dateNavigatorsch_MouseClick(sender, e)
    [/QUOTE]
    Originally posted by gracepaul

    The above code raise the following errors as follows



    The best overloaded method match for 'Scheduling.f1. dateNavigatorsc h_MouseClick(ob ject, System.Windows. Forms.MouseEven tArgs)' has some invalid arguments



    Argument '2': cannot convert from 'System.EventAr gs' to 'System.Windows .Forms.MouseEve ntArgs'


    Please reply if anyone have an idea...

    Thanks in advance

    Grace
    Your code fragment doesn't show us were 'e' is created or where 'sender' is created. So we just have to guess for now.

    If you want to actually call the MouseEvent_Clic k then you have to have arguments that correspond. I.E. MouseEventArgs

    You could either create new MouseEventArgs and send them -or- you could take a slightly different approach.

    Give the MouseEvent_Clic k handler only one line to perform: Calling another method. You didn't mention what that does, so lets assume it is some sort of setup method since you want to call it upon opening. Have the Form1 MouseEvent_Clic k event call your method...

    [CODE=c]public void SetupForm1()
    {
    // Cool setup code here
    }[/CODE]

    Then when you create the new Form1 instance you can now call the new setup method.

    [CODE=c]F1.SetupForm1() ;[/CODE]

    Now you can call the method whenever you like, from where ever you like without pretending someone has clicked on the control.

    Comment

    Working...