Parameter problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • wivked
    New Member
    • Jun 2010
    • 3

    Parameter problem

    Hi all,

    I have this problem,

    I want to return certain value's from a method.
    And that method has a parameter.

    And i want to use that return value in a
    other method, but it i dont have the
    correct parameters for the method.

    Example.
    Code:
     
    
    
     private void button1_Click(object sender, EventArgs e)
     {
     click(e);
     
     }
    
    
    public Point click(MouseEventArgs e)
    {
    
    Point p = new Point(e.X, e.Y);
    
    return p;
     
    }
    
    public void get()
    {
    
    point l = click(); //this wont work because i need a parameter, but i dont have one. Because i only want to have the value of e.X and e.Y
    
    }


    BTW, i am a Noob , ;)

    Thank you..

    WIvked
  • Plater
    Recognized Expert Expert
    • Apr 2007
    • 7872

    #2
    Put the code you want to run in your own function, then you can call that function from anywhere.

    For example:
    [code=c#]
    private void ReloadDataButto n_Click(object sender, EventArgs e)
    {
    ReloadData();
    }

    private void ReloadData()
    {
    //do stuff to reload the data here
    }
    [/code]

    Now I can call ReloadData() from anywhere (I call it when my form loads and whenever the button is clicked)

    Comment

    Working...