Drag/Drop with instance of subclasses problem

  • Thread starter Thread starter Henrik Dahl
  • Start date Start date
H

Henrik Dahl

Hello!

I have a typical GoF Composite Pattern. It means an abstract Component class
and two concrete classes Primitive and Composite.

In my DoDragDrop() method call I'll therefore pass an object reference to
either an instance of Primitive or of Composite.

To my Data.GetData() I would obviously like to be able to pass the type of
the abstract base class: Data.GetData(TypeOf(Component)), but this returns
null despite the Data object actually contains an instance of Composite.

How do I make this simple ordinary case to work, i.e. how do I obtain an
instance of any subclass of a given base class?


Best regards,

Henrik Dahl
 
Try casting your Composite and Primitive objects to Component before setting
the data and .GetData(typeof(Component)) should not return null
Just my thought :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top