Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Accessing methods/properties in the initial form...

Accessing methods/properties in the initial form...

Scheduled Pinned Locked Moved C#
visual-studiocsharpcomhelpquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Andrew Connell
    wrote on last edited by
    #1

    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

    J 1 Reply Last reply
    0
    • A Andrew Connell

      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

      J Offline
      J Offline
      JerzyPeter
      wrote on last edited by
      #2

      Just cast to you class: (MainContainer )(this.theTopMenu.ParentForm).SomeMethod() Jerzy

      J 1 Reply Last reply
      0
      • J JerzyPeter

        Just cast to you class: (MainContainer )(this.theTopMenu.ParentForm).SomeMethod() Jerzy

        J Offline
        J Offline
        JerzyPeter
        wrote on last edited by
        #3

        Or do this: MainContainer mc=(MainContainer)(this.theTopMenu.ParentForm) Then: mc.SomeMethod() mc.AnotherMethod() Jerzy

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups