Click to See Complete Forum and Search --> : Spine referencing Parent Form
ekim12987
Jan 24th, 2007, 08:40 AM
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.
Jumpercables
Jan 24th, 2007, 11:12 AM
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.
jmcilhinney
Jan 24th, 2007, 04:00 PM
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.
ekim12987
Jan 25th, 2007, 08:06 AM
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.
ekim12987
Jan 25th, 2007, 09:43 AM
Is there a way to inherit the parent form?
jmcilhinney
Jan 25th, 2007, 04:38 PM
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.
ekim12987
Jan 25th, 2007, 08:30 PM
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.
jmcilhinney
Jan 25th, 2007, 09:08 PM
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.
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.