I create a form that will serve as InputBox
public partial class InputBox : Form
{
public string sample
{
get
{ return TextBox1.Text; }
set
{ TextBox1.Text = value; }
}
public InputBox(string title, string question)
{
this.Text = title;
Label1.Text = question;
InitializeComponent();
}
}
In my other form I call this form:
private void Button1_Click(object sender, EventArgs e)
{
InputBox dlg = new InputBox("TITLE", "Sample Question ?");
dlg.ShowDialog();
if (dlg.DialogResult == DialogResult.OK)
{
TextBox1.Text = dlg.sample;
}
}
Why I got NullReferenceException? Object reference not set to an instance of an object.