bittersweetryan Posted January 16, 2004 Posted January 16, 2004 I've been exploring message boards for 2 hours now and I am reaching new levels of insanity!! What I'm trying to do is call a method that will update a label on another form. One form loads data and compares it and sends a percentage done to the form that loaded it. I directly cast the forms owner to the calling type and try to call the method but I get a "object reference not set to an instance of an object" error. See code below. If anybody can help me, or point me to a place where this has been answered before I'll be forever grateful! ************************************* * frmSplash - form to recieve method calls * ************************************* ... public frmSplash { mdiMain mdm = new mdiMain(); mdm.Show(); } ... public void setLabel(string text) { this.lblStatus.Text = text; this.Refresh(); } ************************************* * mdiMain - form that calls setLabel * ************************************* ... frmSplash splash = (frmSplash)this.Owner; splash.setLabel("Set the label text!"); ... Quote
*Experts* mutant Posted January 16, 2004 *Experts* Posted January 16, 2004 You are using the Owner property without actually setting the Spalsh as the owner. It will throw an error if there is no instance of the form in the Owner property. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.