locked
Object Reference is Required RRS feed

  • Question

  • User974100899 posted
    I am trying to dynamically create a control and add to my win form. This is my code but I get the error

    Public partial class Form1: System.Windows.Forms.Form
    {
    Public static BindingSource bs = new BindingSource();
    Public static BindingNavigator bn = new BindingNavigator();

    Public Form1_Load()
    {
    //code here
    bs.DataSource = testdatatable;
    bn.BindingSource = bs;
    bn.Dock = DockStyle.Bottom;

    //this is error line when I try to add control
    Controls.Add(bn);
    }
    }

    What do I need to alter so this syntax from the code behind will add my binding navigator?
    Thursday, May 3, 2018 5:37 PM

Answers