Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / October 2004

Tip: Looking for answers? Try searching our database.

Modifying another forms properties?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Chris Ashley - 12 Oct 2004 15:15 GMT
I have a main form with a panel in which loads other forms. How can I let
the forms loaded into panels modify properties of the main form?

If I use:

FrmMain.Text = "Whatever"

from my panel form, I get the error: "Reference to a non-shared member
requires an object reference.". Do I need to create a static method in my
main form code or something?

Sorry if this is a silly question!

TIA,

Chris
Sijin Joseph - 13 Oct 2004 05:33 GMT
One way would be pass an instance of the MainForm in either the
constructor or in a seperate method to the child forms.

Something like this
ChildForm cf = new ChildForm(this);
this.Panel1.Controls.Add(cf);

and inside ChildForm
public ChildForm(Form parentForm)
{
    parentForm.Text = "Whatever";
}

A cleaner approach would be to use Interfaces, but the above will work
too, let me know if you have any problems getting this implemented.

Sijin Joseph
http://www.indiangeek.net
http://weblogs.asp.net/sjoseph

> I have a main form with a panel in which loads other forms. How can I let
> the forms loaded into panels modify properties of the main form?
[quoted text clipped - 12 lines]
>
> Chris

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.