In my listbox form I want to make it possible to call a method from a class in a different folder. Here is what I thought I was meant to do:
public void ListBox_SelectedIndexChanged(object sender, EventArgs e)
{
SharedClasses.Form.FormConsole newFormConsole =
new SharedClasses.Form.newFormConsole();
}
You are creating a new instance of the
FormConsoleclass, which I’m guessing is probably not what you wanted to do.What you probably want to do is have the form that contains your ListBox have a reference to an existing instance of
FormConsole. Then you can call methods on that instance.So, somewhere in the class that contains your ListBox:
You can set that in the constructor for your class, or provide a getter and setter:
Then you can call (public) methods on myForm: