it was work before but now not working why i dont know what is the issue?
in example have 2 forms form1 have 1 button form2 have 1 textbox when start the program and click the button form1 should close, form2 open and delegate variable should write in textbox but not work. Error is "System.NullReferenceException occurred"
public partial class Form1 : Form
{
public delegate void kapatici(string al);
public static event kapatici kapat;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
kapat("deneme");
Form2 f = new Form2();
f.ShowDialog();
}
}
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
private void Form2_Load(object sender, EventArgs e)
{
Form1.kapat += Form1_kapat;
}
private void Form1_kapat(string al)
{
textBox1.Text = al;
//throw new NotImplementedException();
}
}
I've tried different types like
private void button1_Click(object sender, EventArgs e)
{
Form2 f = new Form2();
f.ShowDialog();
kapat("deneme");
}
but still not working. thank you for your answers.