I'm trying to add rows from a class to a datagridview which is in my main_form. To access, I'm using the method posted by vr_driver here
TextBox t = Application.OpenForms["Form1"].Controls["textBox1"] as TextBox;
It works for a datagridview on my brand new project, but in the old project which contains more elements it doesn't. It always comes with : System.NullReferenceException as also did to Deniz on the comment.
DataGridView t = Application.OpenForms["form_main"].Controls["gridSchedule"] as DataGridView;
row = t.Rows.Count = System.NullReferenceException
What could be possible wrong? I already set the modifier for Public.
Thank you.