Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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!");

...

  • *Experts*
Posted
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.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...