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