I use to write nested c and poorly qualified in C #.
My problem is that I want to be able to run the function openAnotherForm()from Welcome_Form, and now the code is not working. I patiently tried different things, but only managed to push my disappointment.
I simplified my relevant code to illustrate the problem.
File 1 - this will start and file 2 will open.
class UIcode
{
private Welcome_Form Welcome;
private AnotherForm_Form AnotherForm;
public UIcode()
{
Welcome = new Welcome_Form();
Application.Run(Welcome);
}
public void openAnotherForm()
{
Welcome.Hide();
AnotherForm = new AnotherForm_Form();
AnotherForm.ShowDialog();
}
}
File 2 - When I click TheButton, the program should run the function openAnotherFromfrom file 1.
public partial class Welcome_Form : Form
{
public Welcome_Form()
{
InitializeComponent();
}
private void TheButton_Click(object sender, EventArgs e)
{
UIcode.openAnotherForm();
}
}
I understand that the problem can be quite trivial, but I will still be grateful for an explanation of how to do this.
Preferably: functions from the UI code should only be recognized by the classes specified in the UI code.
source
share