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. Custom Component Functions

Custom Component Functions

Scheduled Pinned Locked Moved C#
4 Posts 3 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.
  • O Offline
    O Offline
    obelisk29
    wrote on last edited by
    #1

    Hello how do you have a blue button in the property's page that links to a function in your component (eg: The blue button that says 'Generate Dataset' on the DataAdapter object) TIA Obe ------------------ I'm naked under my clothes...

    H 1 Reply Last reply
    0
    • O obelisk29

      Hello how do you have a blue button in the property's page that links to a function in your component (eg: The blue button that says 'Generate Dataset' on the DataAdapter object) TIA Obe ------------------ I'm naked under my clothes...

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

      There are no "functions" in .NET - only methods (procedures on an entity such as a class or struct). :) The button can easily be blue by setting Button.BackColor (inheritted from Control) to Color.Blue. In order to execute a method on another object elsewhere, you'll have to pass an instance of that object to the property page. You could also expose an instance of this object as a static property of another class, but this is not recommended. Mixing statics and instances is like mixing cats and dogs (maybe not as violent, but they just don't belong together). For instance, lets say that this property page is bound to certain objects in a class that encapsulates the logic for generating your DataSet. Pass that entire object to the constructor for the property page (or a property or something). Bind the properties and when the button is clicked, you already have an instance of the aforementioned class so just call the instance method. Just try to encapsulate your logic into distinct units and passing references to them when possible.

      -----BEGIN GEEK CODE BLOCK----- Version: 3.21 GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++ -----END GEEK CODE BLOCK-----

      D 1 Reply Last reply
      0
      • H Heath Stewart

        There are no "functions" in .NET - only methods (procedures on an entity such as a class or struct). :) The button can easily be blue by setting Button.BackColor (inheritted from Control) to Color.Blue. In order to execute a method on another object elsewhere, you'll have to pass an instance of that object to the property page. You could also expose an instance of this object as a static property of another class, but this is not recommended. Mixing statics and instances is like mixing cats and dogs (maybe not as violent, but they just don't belong together). For instance, lets say that this property page is bound to certain objects in a class that encapsulates the logic for generating your DataSet. Pass that entire object to the constructor for the property page (or a property or something). Bind the properties and when the button is clicked, you already have an instance of the aforementioned class so just call the instance method. Just try to encapsulate your logic into distinct units and passing references to them when possible.

        -----BEGIN GEEK CODE BLOCK----- Version: 3.21 GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++ -----END GEEK CODE BLOCK-----

        D Offline
        D Offline
        David Stone
        wrote on last edited by
        #3

        Err...Heath...I think he was talking about the PropertyGrid control. When you have certain classes selected, there's this little section added to the bottom of it with links. His particular example was the DataAdapter class. If you drag one onto your form, and then click on it in the components tray, and view its properties, then you'll see links at the bottom like "Configure Data Adapter" or "Generate DataSet".


        youd ebtter bnot be taki8ng agvantage o f my mental abilites!1 -David Wulff one night over MSN while totally plastered

        H 1 Reply Last reply
        0
        • D David Stone

          Err...Heath...I think he was talking about the PropertyGrid control. When you have certain classes selected, there's this little section added to the bottom of it with links. His particular example was the DataAdapter class. If you drag one onto your form, and then click on it in the components tray, and view its properties, then you'll see links at the bottom like "Configure Data Adapter" or "Generate DataSet".


          youd ebtter bnot be taki8ng agvantage o f my mental abilites!1 -David Wulff one night over MSN while totally plastered

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

          In that case, derive from the appropriate ComponentDesigner and override the Verbs property to return a collection of DesignerVerb objects (see documentation in .NET Framework SDK for more information about these classes - it's really pretty straight-forward). Finally, attribute your component with the DesignerAttribute attribute, passing the Type of your designer from above to the constructor of the attribute. For more information, see Enhancing Design-Time Support[^] in the .NET Framework. Sorry for the confusion - it's late.

          -----BEGIN GEEK CODE BLOCK----- Version: 3.21 GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++ -----END GEEK CODE BLOCK-----

          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