I need to run the code of a button that is on another form. is it possible to do it from a different form? if you say that it is possible by declaring it public then:
<
You can use internal as your modifier, so you can easily access the click event.
for example you have a click event in form1. instead of making it private, public or protected. put it as internal this way you can easily access the method in other classes. But the internal modifier is only accessible within the current package.
Form1
internal passobj;
internal passeargs;
internal void button1_Click(object obj, EventArgs e)
{
this.passobj = obj;
this.passeargs = e;
MessageBox.Show("Clicked!")
}
Form2
private void button1_Click(object obj, EventArgs e)
{
Form1 f1 = new Form1();
f1.button1_Click(f1.passobj, f1.passeargs);
}