Accessing methods/properties in the initial form...
-
I'll start with saying that it's somewhat difficult explaining exactly what I am having trouble with, so bear with me.. My application loads an initial form (MainContainer). This form, uses another class file (PAMenu) within the project to build & return an object containing a control menu. The PAMenu contains all of the menu construction, changes, and event handlers. It uses a 3rd party control (MagicLibrary) to build the menu (giving it the OfficeXP/VS.NET menu appearance). My problem is that I am having trouble accessing methods & properties in the MainContainer form from the event handlers. Here's a bit of code: [MainContainer] private PAMenu thePAMenu = new PAMenu(); appMenu = thePAMenu.Menu(); // builds the menu with default settings & display settings Controls.Add(appMenu); [PAMenu] //this simply builds the menu and contains event handlers //the internal menu object is called 'theTopMenu' [MagicLibrary] //this control overloads the MenuControl and MenuCommand objects I have no problem handling events if they don't interact with the MainContainer or it's child forms (such as the Exit handler running Application.Exit()), but calling a public method within MainContainer just isn't working. I've tried the following from within an event handler in PAMenu: this.theTopMenu.ParentForm which gave me access to the default properties of the MainContainer form (I was able to change the text in the titlebar), but I can't see my exposed methods. The odd thing is that I can see some of the private properties when stepping through intellisense. Any ideas? Andrew Connell IM on MSN andrew@aconnell.com
-
I'll start with saying that it's somewhat difficult explaining exactly what I am having trouble with, so bear with me.. My application loads an initial form (MainContainer). This form, uses another class file (PAMenu) within the project to build & return an object containing a control menu. The PAMenu contains all of the menu construction, changes, and event handlers. It uses a 3rd party control (MagicLibrary) to build the menu (giving it the OfficeXP/VS.NET menu appearance). My problem is that I am having trouble accessing methods & properties in the MainContainer form from the event handlers. Here's a bit of code: [MainContainer] private PAMenu thePAMenu = new PAMenu(); appMenu = thePAMenu.Menu(); // builds the menu with default settings & display settings Controls.Add(appMenu); [PAMenu] //this simply builds the menu and contains event handlers //the internal menu object is called 'theTopMenu' [MagicLibrary] //this control overloads the MenuControl and MenuCommand objects I have no problem handling events if they don't interact with the MainContainer or it's child forms (such as the Exit handler running Application.Exit()), but calling a public method within MainContainer just isn't working. I've tried the following from within an event handler in PAMenu: this.theTopMenu.ParentForm which gave me access to the default properties of the MainContainer form (I was able to change the text in the titlebar), but I can't see my exposed methods. The odd thing is that I can see some of the private properties when stepping through intellisense. Any ideas? Andrew Connell IM on MSN andrew@aconnell.com
Just cast to you class: (MainContainer )(this.theTopMenu.ParentForm).SomeMethod() Jerzy
-
Just cast to you class: (MainContainer )(this.theTopMenu.ParentForm).SomeMethod() Jerzy
Or do this: MainContainer mc=(MainContainer)(this.theTopMenu.ParentForm) Then: mc.SomeMethod() mc.AnotherMethod() Jerzy