473,471 Members | 1,722 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Determing if an object is a parent of another object

I've subclassed the TreeNode class and created:

NodeAbstract : TreeNode

NodeFolder : NodeAbstract
NodeFile : NodeAbstract

The nodes have been added to a Treeview.
Now, I would like to do a drag and drop between nodes inside the
treeview.

I reference all the nodes with the type NodeAbstract although the
nodes are of type NodeFile or NodeFolder.

When I do the drag and drop I use the following code

if (e.Data.GetDataPresent("NodeAbstract"))
//DO something
but it doesn't work because the node is of type NodeFolder or
NodeFile.

How can I solve the problem? I need the code to be executed if the
element inherits from NodeAbstract.
Thanks a lot.
Nov 16 '05 #1
3 1188
First check the type

if(treeNode.GetType().BaseType.ToString() == "NodeAbstract")
{
//do something
}
--
Shak
(Houston)


"kurotsuke" <ku*******@yahoo.it> wrote in message
news:28********************************@4ax.com...
I've subclassed the TreeNode class and created:

NodeAbstract : TreeNode

NodeFolder : NodeAbstract
NodeFile : NodeAbstract

The nodes have been added to a Treeview.
Now, I would like to do a drag and drop between nodes inside the
treeview.

I reference all the nodes with the type NodeAbstract although the
nodes are of type NodeFile or NodeFolder.

When I do the drag and drop I use the following code

if (e.Data.GetDataPresent("NodeAbstract"))
//DO something
but it doesn't work because the node is of type NodeFolder or
NodeFile.

How can I solve the problem? I need the code to be executed if the
element inherits from NodeAbstract.
Thanks a lot.

Nov 16 '05 #2
You may have to just get the data instead, as an object, and then check to
see if it's of that type (eg. if (obj is NodeAbstract) ...)

--
John Wood
email: john dot wood at priorganize dot com

"kurotsuke" <ku*******@yahoo.it> wrote in message
news:28********************************@4ax.com...
I've subclassed the TreeNode class and created:

NodeAbstract : TreeNode

NodeFolder : NodeAbstract
NodeFile : NodeAbstract

The nodes have been added to a Treeview.
Now, I would like to do a drag and drop between nodes inside the
treeview.

I reference all the nodes with the type NodeAbstract although the
nodes are of type NodeFile or NodeFolder.

When I do the drag and drop I use the following code

if (e.Data.GetDataPresent("NodeAbstract"))
//DO something
but it doesn't work because the node is of type NodeFolder or
NodeFile.

How can I solve the problem? I need the code to be executed if the
element inherits from NodeAbstract.
Thanks a lot.

Nov 16 '05 #3
ew that's terrible.. if that was what he was trying to do, a much cleaner
approach would be:
if (treeNode is NodeAbstract)
{
...
}

But it's not... he wants to see the type of the data in the drop operation.

--
John Wood
email: john dot wood at priorganize dot com
"Shakir Hussain" <sh**@fakedomain.com> wrote in message
news:eS**************@TK2MSFTNGP10.phx.gbl...
First check the type

if(treeNode.GetType().BaseType.ToString() == "NodeAbstract")
{
//do something
}
--
Shak
(Houston)


"kurotsuke" <ku*******@yahoo.it> wrote in message
news:28********************************@4ax.com...
I've subclassed the TreeNode class and created:

NodeAbstract : TreeNode

NodeFolder : NodeAbstract
NodeFile : NodeAbstract

The nodes have been added to a Treeview.
Now, I would like to do a drag and drop between nodes inside the
treeview.

I reference all the nodes with the type NodeAbstract although the
nodes are of type NodeFile or NodeFolder.

When I do the drag and drop I use the following code

if (e.Data.GetDataPresent("NodeAbstract"))
//DO something
but it doesn't work because the node is of type NodeFolder or
NodeFile.

How can I solve the problem? I need the code to be executed if the
element inherits from NodeAbstract.
Thanks a lot.


Nov 16 '05 #4

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

Similar topics

14
by: pablo | last post by:
Dear NewsGroupers, I am relatively new to OOP and cannet get my head around this problem. I have two classes. Class Child extends Parent. There is no constructor for the Child class. So when I...
6
by: Squeamz | last post by:
Hello, Say I create a class ("Child") that inherits from another class ("Parent"). Parent's destructor is not virtual. Is there a way I can prevent Parent's destructor from being called when a...
35
by: Frederick Gotham | last post by:
(Before I begin, please don't suggest to me to use "std::vector" rather than actual arrays.) I understand that an object can have resources (e.g. dynamically allocated memory), and so we have to...
5
by: BL | last post by:
Hello I need to get a parent object of an object. I how to get the instance of an object in which current object created. is it possible in c# ? Thank
0
by: zman77 | last post by:
EDIT: -- forgot to mention... I am using Visual Studio 2005, on Win XP, on an intel machine Hi. This is my first post, though I've "lurked" for a while because I find these forums very helpful....
3
by: Maximiliano | last post by:
Hello, I have an asp.net project that calculates a general tax. Ok, this tax is a big object formed with another child objects (as a mather of fact 15 another child object within it), like Ship,...
0
by: hott5hotj | last post by:
in Actionscript 3.0 Ive created a datagrid that populated with data. I want to create a pop up window to confirm whether the removal of an entry. When I call from the child object the following, I...
7
by: joproulx | last post by:
Hi, I was wondering if there was a way with Reflection to find dynamically if an object was referencing indirectly another object. A simple example would be: Object1 | --Object2 |
3
by: toyaxxx | last post by:
Hello guys, I have hit a dead end in trying to solve this problem. The thing is, I can't run the the program here because it has to run on a server which is in another place. All I receive here is...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
1
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...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...

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.