I have a form with a groupbox but is initializing its controls from another class. along with the controls is a button with its event declared in the initializing class. Now I need to access the properties of the buttons that is programmatically initialized. I use these commands:
private void buttonUniAdd_Click(object sender, EventArgs e)
{
myProg.Misc frmMisc = (myProg.Misc)System.Windows.Forms.Application.OpenForms["Misc"];
System.Windows.Forms.Button btnAdd = (System.Windows.Forms.Button)frmMisc.Controls["buttonOAdd"];
btnAdd.Text = "&Cancel"; //<-- exception during runtime
}
unfortunately this causes the exception "Object reference not set to an instance of an object.". These are all inside the initialization class that I made.