I have narrowed down what is causing the issue, but uncertain how to remedy. The issue is that once the InputCtrl ic = new InputCtrl();
is called from within my method PopulateData()
I receive an error of
Object reference is not set to an instance of an object
Now to me, I am setting it to an instance of an object with the variable ic
Backstory on what is going on here, I have a form loading, that on load, should generate a "new screen", essentially a "blank slate" for the user to begin inputting data into. Now the top 3 text boxes will populate no problem, the only reason I can think of is that they exist on the main form, while the 4 below exist on the input control.
What should be altered in this syntax so that it executes accordingly?
private void MainForm_Load(object sender, EventArgs e)
{
NewScreen("new", new DFC());
}
void NewScreen(string strNewTabName, DFC validinput)
{
InputCtrl nsc = new InputCtrl();
nsc.Location = new Point(0, 0);
nsc.Anchor = (AnchorStyles)(AnchorStyles.Top | AnchorStyles.Left);
nsc.Size = new Size(828, 689);
nsc.Name = "DrawingStageCtrl1";
nsc.TabIndex = 0;
nsc.Dock = DockStyle.Fill;
nsc.Setvalidinput(validinput);
TabPage NewtabPage = new TabPage();
NewtabPage.Location = new Point(4, 22);
NewtabPage.Name = "tabPage1";
NewtabPage.Padding = new Padding(3);
NewtabPage.Size = new Size(828, 689);
NewtabPage.TabIndex = 0;
NewtabPage.Text = strNewTabName;
NewtabPage.UseVisualStyleBackColor = true;
NewtabPage.Controls.Add(nsc);
MainTabCtrl.Controls.Add(NewtabPage);
MainTabCtrl.SelectedTab = NewtabPage;
CurrentSelectedCtrl = nsc;
PopulateData(validinput);
}
public void PopulateData(DFC validinput)
{
txta.Text = validinput.a.ToString();
txtb.Text = validinput.m_b.ToString();
txtc.Text = validinput.m_c.ToString();
InputCtrl ic = new InputCtrl();
ic.txtpb.Text = validinput.m_pb.ToString();
ic.d.Text = validinput.m_d.ToString();
ic.pn.Text = validinput.m_pn.ToString();
ic.ls.Text = validinput.m_ls.ToString();
}