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. Get a reference to the Form from a IComponent on the ComponentTray

Get a reference to the Form from a IComponent on the ComponentTray

Scheduled Pinned Locked Moved C#
question
5 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.
  • D Offline
    D Offline
    Daniel Zaharia
    wrote on last edited by
    #1

    I have a IComponent (like DataSet) on the ComponentTray of a Form. Having only this IComponent , how can i get a reference to the Form? Thanks.

    H 1 Reply Last reply
    0
    • D Daniel Zaharia

      I have a IComponent (like DataSet) on the ComponentTray of a Form. Having only this IComponent , how can i get a reference to the Form? Thanks.

      H Offline
      H Offline
      Heath Stewart
      wrote on last edited by
      #2

      Get the Site property (returns an ISite). Then get the Container property. There's your container for the component.

      Microsoft MVP, Visual C# My Articles

      D 1 Reply Last reply
      0
      • H Heath Stewart

        Get the Site property (returns an ISite). Then get the Container property. There's your container for the component.

        Microsoft MVP, Visual C# My Articles

        D Offline
        D Offline
        Daniel Zaharia
        wrote on last edited by
        #3

        I have already tried that, and it returns an Microsoft.VisualStudio.Designer.Host. I think that probably i should use Site.GetService to get an appropriate service that have a reference to the form. But i don't know what service is that (or even if it exist..). Thanks

        H 1 Reply Last reply
        0
        • D Daniel Zaharia

          I have already tried that, and it returns an Microsoft.VisualStudio.Designer.Host. I think that probably i should use Site.GetService to get an appropriate service that have a reference to the form. But i don't know what service is that (or even if it exist..). Thanks

          H Offline
          H Offline
          Heath Stewart
          wrote on last edited by
          #4

          I guess it returns that because during design-time it's hosted in the component tray. The service that should help would be the System.ComponentModel.Design.IReferenceService.

          Microsoft MVP, Visual C# My Articles

          D 1 Reply Last reply
          0
          • H Heath Stewart

            I guess it returns that because during design-time it's hosted in the component tray. The service that should help would be the System.ComponentModel.Design.IReferenceService.

            Microsoft MVP, Visual C# My Articles

            D Offline
            D Offline
            Daniel Zaharia
            wrote on last edited by
            #5

            It is exactly whant i was lookinig for!! Tahnks!

            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