Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I am using an MDI in my application which has a progress bar on the bottom. I would like to control this progress bar from within the child MDI's. E.g Click button on Child FOrm 1 that loads child form 2 - progress bar on MDI parent shows progress.

 

Thanks for any help you give.

Visit: VBSourceSeek - The VB.NET sourcecode library

 

 

"A mere friend will agree with you, but a real friend will argue."
  • *Experts*
Posted

You'll need to somehow get access to that control or to a method/property that can set the control. There's a couple of ways to do this. The easiest is probably to pass a reference to *exact* type of MDIForm to the child forms. So if your MDI form's class is named "frmMain", then add a parameter to the contstructor of Form1 like so (C#):

private frmMain myParent;

public Form1 (frmMain myParent)
{
   this.myParent = myParent;
}

private void btnClick(...)
{
   myParent.progressBar1.Value = 50;
}

 

The above assumes that the modifier for frmMain's progress bar is set to Public instead of the default private.

 

When frmMain creates an instance of Form1, it would use something like this:

private void mnuClick(...)
{
   // Pass "this" to the constructor of Form1 so
   // that it has a reference and can reach progressBar1
   Form1 f = new Form1(this);
   f.MDIParent = this;
   f.Show();
}

 

-Nerseus

"I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut

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...