Results 1 to 8 of 8

Thread: Spine referencing Parent Form

  1. #1

    Thread Starter
    Member
    Join Date
    Mar 2006
    Posts
    58

    Spine referencing Parent Form

    I have a project with a user control spine down the left hand side of MainForm. The MainForm contains a panel (pnlContent) that displays multiple usercontrols. (ConsumerView, ReportView..) When I click on, we'll say Consumers in the spine, I want ConsumerView to be loaded onto the panel in the mainform. But my problem is that I am unable to access pnlContent. Ive tried this.Parent.Controls, but I am still not able to access pnlContent. Is there a trick to this that I am not understanding? Thanks.

  2. #2
    Fanatic Member Jumpercables's Avatar
    Join Date
    Jul 2005
    Location
    Colorado
    Posts
    592

    Re: Spine referencing Parent Form

    I am not positive about this but you might try using something called Controls.Target where you can load your control into the pnlContent panel. When I have a larger break from work I will try to find what I mean.

    C# - .NET 1.1 / .NET 2.0

    "Take everything I say with a grain of salt, sometimes I'm right, sometimes I'm wrong but in the end we've both learned something."
    _____________________
    Regular Expressions Library
    Connection String
    API Functions
    Database FAQ & Tutorial

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Spine referencing Parent Form

    Is this VS 2005? Please always specify your version.

    VS 2005 has introduced the ability to not create a member variable for components you add in the designer. This is a good thing because it means that objects that don't need to be referenced, like GroupBoxes, can't be. I'm guessing that you set the GenerateMember property of your Panel to False, which specifically uses only a local variable to create the Panel in the InitializeComponent method.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  4. #4

    Thread Starter
    Member
    Join Date
    Mar 2006
    Posts
    58

    Re: Spine referencing Parent Form

    I am using VS 2005. So you think that all I need to do is change the GenerateMember property to True? This problem has really been confusing me.

  5. #5

    Thread Starter
    Member
    Join Date
    Mar 2006
    Posts
    58

    Re: Spine referencing Parent Form

    Is there a way to inherit the parent form?

  6. #6
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Spine referencing Parent Form

    Quote Originally Posted by ekim12987
    Is there a way to inherit the parent form?
    I don't quite understand how this relates to the original question. You can add inherited forms to your project as easily as you add standard forms, but if you're looking to that as a way to accomplish something relating to your original question then I think you're on the wrong track. Can you explain further? If this is unrelated to the original question then it should have been asked in a new thread.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  7. #7

    Thread Starter
    Member
    Join Date
    Mar 2006
    Posts
    58

    Re: Spine referencing Parent Form

    Sorry, it was related to the original question. I was thinking that maybe that would allow me to access the controls on the parent form.

  8. #8
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Spine referencing Parent Form

    Inheriting a class is not going to help you there. If you need to access an object, any object, then you need a reference to it. If your second form needed to use a string from the first form what would you do? You'd assign that string to a property of the second form or pass it to a method argument. If the second form needs data then the first form passes that data to it. If that data is the first form itself then that's what gets passed. In that case the first form would pass this to the second form.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width