Really the best thing to do is to not code that way.
Write a method that performs the action you need.
Have the Click event call that method.
Have your second method call that method.
- Public void myButton_Click(object sender, eventargs e)
-
{
-
SaveFile();
-
}
-
-
public void CompletlyDifferentMethod()
-
{
-
SaveFile();
-
}
-
private void SaveFile()
-
{
-
// This is the Saving method
-
}
But... If you insist on putting the meat of your code in the button click method and want to call it...
- myButton_Click(this, eventargs.empty);
... will usually do the trick.
All the button click does is call a method with two parameters: An object and an eventargs. You are going to do the same this. You send it an object (usually 'this' or 'null' will due) and an eventargs.