7 Replies - 5339 Views - Last Post: 17 September 2013 - 04:34 AM Rate Topic: -----

#1 Aeriq  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 16-September 13

Opening form from another child form in MDI splitcontainer

Posted 16 September 2013 - 11:15 AM

I need to open a form from another MDI child form , but i want to show all the forms in splitcontainer's panel 2 which is located on the MDI parentform,the following code doesnt help

childForm2 form2= new childForm2();
form2.MdiParent = this.MdiParent; 
form2.Show();


as i want to show the new form in mdiparent's splitcontainer's panel2
the first child form is shown in panel2 by the use of following code:
[splitContainer1.Panel2.Controls.Add(form1);]
form1 is the object name of first child form which is opened directly from MDIparent
but when i try to use the same code for childform2 it shows an error at splitContainer1
the error is as follows: "The name splitContainer1 does not exist in the current context"
kindly help me asap
i want code in c#

This post has been edited by Curtis Rutland: 16 September 2013 - 11:48 AM


Is This A Good Question/Topic? 0
  • +

Replies To: Opening form from another child form in MDI splitcontainer

#2 Michael26  Icon User is offline

  • Futurama: Insert funny joke here
  • member icon

Reputation: 414
  • View blog
  • Posts: 1,664
  • Joined: 08-April 09

Re: Opening form from another child form in MDI splitcontainer

Posted 16 September 2013 - 11:17 AM

Does the childForm2 contain reference to splitContainer1?
Was This Post Helpful? 0
  • +
  • -

#3 Aeriq  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 16-September 13

Re: Opening form from another child form in MDI splitcontainer

Posted 16 September 2013 - 11:52 AM

no

how can i add reference to splitcontainer1 from childform2 ??
does that help
Was This Post Helpful? 0
  • +
  • -

#4 Michael26  Icon User is offline

  • Futurama: Insert funny joke here
  • member icon

Reputation: 414
  • View blog
  • Posts: 1,664
  • Joined: 08-April 09

Re: Opening form from another child form in MDI splitcontainer

Posted 16 September 2013 - 11:54 AM

That means you have defined splitcontainer1 somewhere else, read about the scope of the variable and what it is.
Here is an example of scope
class someClass
{
   int yogi = 5; // Accessible to the class
   
   void someMethod()
   {
        int booboo = 3; // Accessible to the method

        while(true)
        {
           string Ranger = "Smith"; // Accessible to the loop
        }
   }
}


Each variable has it's own type(Ranger is string, booboo is int, yogi is int), they have value only in their respective scope, for example string ranger will have value Smith only inside while loop, once the loop break and program flow resumes string ranger will lose it's value.

This post has been edited by Michael26: 16 September 2013 - 12:00 PM

Was This Post Helpful? 0
  • +
  • -

#5 Aeriq  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 16-September 13

Re: Opening form from another child form in MDI splitcontainer

Posted 16 September 2013 - 12:00 PM

i understand that
in my case splitcontainer1 is defined in MDIparent form
isnt there any way to access it from outside MDIparent ??
i just want to show a childform in splitcontainer of MDIparent
and that specific childform is called from another child form
Was This Post Helpful? 0
  • +
  • -

#6 Michael26  Icon User is offline

  • Futurama: Insert funny joke here
  • member icon

Reputation: 414
  • View blog
  • Posts: 1,664
  • Joined: 08-April 09

Re: Opening form from another child form in MDI splitcontainer

Posted 16 September 2013 - 12:50 PM

In parent form you can try something like this for example
Form2 chWin = new Form2();
    chWin.MdiParent = this;
    chWin.Show();

public void DisableStrip()
        {
            menuStrip1.Enabled = false;
        }



Then in Form2 you can call the method of Form1 by casting the MdiParent to Form1:

 ((Form1)MdiParent).DisableStrip();


Once again, this an example, adapt this to your example.

This post has been edited by Michael26: 16 September 2013 - 12:53 PM

Was This Post Helpful? 1
  • +
  • -

#7 Curtis Rutland  Icon User is offline

  • (╯□)╯︵ (~ .o.)~
  • member icon


Reputation: 5101
  • View blog
  • Posts: 9,283
  • Joined: 08-June 10

Re: Opening form from another child form in MDI splitcontainer

Posted 16 September 2013 - 03:33 PM

I'm going to go ahead and recommend this tutorial:

http://www.dreaminco...ny-other-forms/

It's not specifically for MDI, but it lays out concepts that you really need to understand before you get deep into this kind of project. Passing values between forms/classes in a loosely coupled model is very important to understand, otherwise you're going to have a mess code with so many dependencies that when you change one thing, you'll have to change dozens of things.
Was This Post Helpful? 1
  • +
  • -

#8 Aeriq  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 16-September 13

Re: Opening form from another child form in MDI splitcontainer

Posted 17 September 2013 - 04:34 AM

Thanks alot
now i understand the logic
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1