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. Generic toolbox component [modified]

Generic toolbox component [modified]

Scheduled Pinned Locked Moved C#
questiondata-structureshelp
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.
  • H Offline
    H Offline
    hain
    wrote on last edited by
    #1

    I have written a generic (i.e., having a type parameter) undo-redo component that I would like to add to the toolbox. The problem is, how can I drag this component to the component tray, and specify the type (of objects on the undo stack). I can't just make the component use system.object, since the objects must be ICloneable (and that would not be "generic" anyway). When the component is dragged onto the component tray, an instance of the component is created, so it needs to know its type. Perhaps, the initial type could be system.object (how would you specify this for the drag?), and then the actual type could be be given as a property of the component, and changed when the property is changed? (How would you do this?) Interesting/challenging problem, huh? (...well, perhaps not for the gurus). Does anyone have an elegant solution? Thanks, Tom

    modified on Friday, March 14, 2008 11:46 AM

    L 1 Reply Last reply
    0
    • H hain

      I have written a generic (i.e., having a type parameter) undo-redo component that I would like to add to the toolbox. The problem is, how can I drag this component to the component tray, and specify the type (of objects on the undo stack). I can't just make the component use system.object, since the objects must be ICloneable (and that would not be "generic" anyway). When the component is dragged onto the component tray, an instance of the component is created, so it needs to know its type. Perhaps, the initial type could be system.object (how would you specify this for the drag?), and then the actual type could be be given as a property of the component, and changed when the property is changed? (How would you do this?) Interesting/challenging problem, huh? (...well, perhaps not for the gurus). Does anyone have an elegant solution? Thanks, Tom

      modified on Friday, March 14, 2008 11:46 AM

      L Offline
      L Offline
      led mike
      wrote on last edited by
      #2

      hain wrote:

      an instance of the component is created

      I think I follow you and, if I do, you need a Designer object that wraps your Generic. So the designer object doesn't need a type parameter to create an instance in the designer. The designer object will generate the code for the generic based on the type as a property the user will set. I imagine you would default this to "object".

      led mike

      H 1 Reply Last reply
      0
      • L led mike

        hain wrote:

        an instance of the component is created

        I think I follow you and, if I do, you need a Designer object that wraps your Generic. So the designer object doesn't need a type parameter to create an instance in the designer. The designer object will generate the code for the generic based on the type as a property the user will set. I imagine you would default this to "object".

        led mike

        H Offline
        H Offline
        hain
        wrote on last edited by
        #3

        I just needed a push in the right direction--and you gave it to me--thanks, led mike. I found a helpful web site: http://www.codeproject.com/KB/architecture/components.aspx[^] Thanks again, Tom

        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