I have the following code:
panel4.Controls.Clear();
panel4.Controls.Add(dgv.addDatagrid(animal, experiment, pluginIdentifier));
dgv.ConfigureDatagrid();
This gets called when a user clicks a node on a treeview. When I click on it the first time, it works as expected and obtains the datagrid and adds it to the panel. However, any subsequent calls, I get the 'Object reference not set to an instance of an object' error on the panel4.Controls.Clear() line. Anybody know why?
Thanks.
panel4, as Controls will never be null afaik.. start by posting code ofConfigureDatagridmethod. Another option is that you got the wrong line and maybedgvis null.panel4is reset somewhere.