I have a function in my Form.cs that I want to summon in my program.cs
But if the function is not static, program.cs can’t use it. And if it’s static, Form.cs can’t use it because it involves controls which aren’t static.
I can delete my program.cs code and find a way to do the same in my form.cs but I was wondering if there is an easier way.
That’s generally what the function in the form.cs does
public void Toggle()
{
MyDomainUpDown.SelectedIndex = 3;
}
The program.cs :
MainForm.Toggle();
Why can’t you access it from your program.cs?
You can easily define a variable to hold the form, and then reference it: