473,668 Members | 2,491 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Drag/Drop with instance of subclasses problem

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(Ty peOf(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
Nov 17 '05 #1
1 1358
Try casting your Composite and Primitive objects to Component before setting
the data and .GetData(typeof (Component)) should not return null
Just my thought :)

"Henrik Dahl" <He********@com munity.nospam> wrote in message
news:uf******** ********@TK2MSF TNGP14.phx.gbl. ..
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(Ty peOf(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

Nov 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2594
by: Lauren Quantrell | last post by:
I'm trying to drop a file from Windows Explorer (or desktop, etc.) onto a field in Access2K and capture the full file path. I found an posting below that says this is possible but I cannot simutate it. Can anyone help? Thanks ************************** previous post: Message 1 in thread
1
1461
by: Derrick | last post by:
I have a basic C# windows forms app where drag and drop of a simple class, no gui, from one tree to another (I store the class instance in the "tag" field of the tree nodes, and drag that) That is working fine within the same app instance. If I start two instances of the same app and try to drag from one app instance to the other, I get the below exception: A first chance exception of type...
1
1564
by: Greg | last post by:
I have a custom control called PageBanner which is compiled into a DLL and then put into the toolbox. It shows like I would expect it to in the toolbox, and I can drag and drop it onto a form. However, instead of getting the control on the form, I get nothing. No error message, no control. Yet there are other times where it does drop on the form as expected. I have tried recompiling the dll with the control and readding it to the...
0
1533
by: Oberon | last post by:
How do I navigate through records using drag 'n' drop controls? I have an example in C# for Windows forms that relies on BindingContext but this is not available for ASP.NET. How do I solve that problem? PS: I don't need a code example showing me how to do it without drag 'n' drop because I already know how. I WANT to learn how to do it with drag 'n' drop.
6
3545
by: jojobar | last post by:
Hello, I look at the asp.net 2.0 web parts tutorial on the asp.net web site. I tried to run it under firefox browser but it did not run. If I want to use this feature in a commercial product where the user can run on firefox/mozilla, what would be a good approach. 1. Should I overwrite the javascript code drag-and-drop to make it more browser independent. If I want to go this route, can anybody provide me a
1
2237
by: Neil West | last post by:
I’m trying to drag & drop listview items between two instances of my app. The actual data that’s passed in DoDragDrop is an arraylist that’s been serialized to a memorystream. The contents of the arraylist are objects of a simple, serializable custom class that allows the recipient listview to reconstruct the dragged listitems. (the contents of the arraylist actually don’t matter…they can be simple integers and the issues in...
1
2298
by: Terry Olsen | last post by:
My first time using TreeViews. I have TreeView1 set up to display my directory structure just like Windows Explorer. I can drag & drop files and folders over to TreeView2. I can re-arrange the structure in TreeView2 (putting files in different folders and such...like you do when you create a structure for burning a CD). I have two questions. 1. How can I remember the full path from TreeView1 (when it comes time to actually do...
0
1698
by: Ellen | last post by:
Hi! Please point me to the correct discussion if I am off base. We are beta testing a new Dot Net Framework application that allows us to upload documents of different file types for online storage with each of our transactions. We can easily drag and drop email attachments to the new application, but we cannot seem to drag and drop an email msg from Outlook. I suspect this may have something to do with security. We are able to export...
1
4475
by: JHuman | last post by:
Hi there, At the moment I'm making an application where I drag an item in a List to a Canvas (all in SWT). However, I don't wish to use TextTransfer or ByteArrayTransfer for the drag and drop data transfer. I want to transfer a class defined by me (lets just call it myCustomObj). I've tried subclassing Transfer but I don't have a clue what to put inside Transfer's methods, particularly isSupportedType() and nativeToJava(). Can anyone help me...
0
8462
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8799
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8586
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8658
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6209
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4205
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4380
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2792
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2026
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.