Click here to Skip to main content
15,893,790 members
Home / Discussions / C#
   

C#

 
AnswerRe: How To Move An Item In A Hierarchy Pin
Luc Pattyn10-May-12 10:45
sitebuilderLuc Pattyn10-May-12 10:45 
AnswerMessage Removed Pin
10-May-12 10:54
SledgeHammer0110-May-12 10:54 
GeneralRe: How To Move An Item In A Hierarchy Pin
Kevin Marois10-May-12 13:03
professionalKevin Marois10-May-12 13:03 
AnswerRe: How To Move An Item In A Hierarchy Pin
Peter_in_278010-May-12 16:26
professionalPeter_in_278010-May-12 16:26 
AnswerRe: How To Move An Item In A Hierarchy Pin
BobJanova11-May-12 4:02
BobJanova11-May-12 4:02 
GeneralRe: How To Move An Item In A Hierarchy Pin
Kevin Marois11-May-12 8:12
professionalKevin Marois11-May-12 8:12 
GeneralRe: How To Move An Item In A Hierarchy Pin
BobJanova14-May-12 4:55
BobJanova14-May-12 4:55 
AnswerRe: How To Move An Item In A Hierarchy Pin
BillWoodruff12-May-12 5:09
professionalBillWoodruff12-May-12 5:09 
Kevin Marois wrote:
I need to provide Move Up and Move Down functions.
I think Bob Janova's suggestion that you include in your Node-whatever base class a 'Parent field is the correct solution, and it will have so much additional functionality, in the long run, it's the "only" solution.

What you leave unspecified in your question are the interesting cases such as:

You wish to move up a child Node of a Parent Node:

a. assuming the Parent Node has other siblings prior to the the Node to be "promoted:" the "promoted node" then remains a sibling of the Parent node, but now precedes the prior sibling in the collection ?

b. assuming the node to be "promoted" is the first child of its Parent Node: the "promoted node" then becomes a sibling of its former Parent node, preceding its former Parent node in the collection ?

I think you can also easily see that you will need to think through other "edge cases" involving moving a Node "down" in the collection/tree.

Also consider that some tree data structures (in computer science algorithmic theory) are based on having a single root node from which all other Nodes descend, and other trees, as you see in the typical TreeView Control in .NET, are based on having an arbitrary collection in which any number of Nodes can be root-level.

Since you use the word "collection" here, I would assume you are allowing multiple root-nodes. In that case the top root-node cannot be moved up, and the last root-node cannot be moved down.

imho it's a useful convention to make the design choice that if the 'Parent field of a Node, in a collection-based tree, contains 'null, then the given Node is a "root-level" node.

Now if you are constructing your own "hierarchic visual display" of this collection/tree structure ... not using some existing TreeView control ... then ... welcome to recursion.

best, Bill
"Humans are amphibians ... half spirit and half animal ... as spirits they belong to the eternal world, but as animals they inhabit time. This means that while their spirit can be directed to an eternal object, their bodies, passions, and imaginations are in continual change, for to be in time, means to change. Their nearest approach to constancy, therefore, is undulation: the repeated return to a level from which they repeatedly fall back, a series of troughs and peaks.” C.S. Lewis

QuestionAdding an item to a sharepoint list. Pin
MitchG92_2410-May-12 4:07
MitchG92_2410-May-12 4:07 
AnswerRe: Adding an item to a sharepoint list. Pin
Not Active10-May-12 6:16
mentorNot Active10-May-12 6:16 
QuestionConvert vb.net to c#.net Pin
Jaydev Jangid10-May-12 0:46
Jaydev Jangid10-May-12 0:46 
AnswerRe: Convert vb.net to c#.net Pin
Richard MacCutchan10-May-12 1:14
mveRichard MacCutchan10-May-12 1:14 
AnswerRe: Convert vb.net to c#.net Pin
Sandeep Mewara10-May-12 4:46
mveSandeep Mewara10-May-12 4:46 
QuestionRemove Object From Hierarchical Collection Pin
Kevin Marois9-May-12 11:56
professionalKevin Marois9-May-12 11:56 
AnswerRe: Remove Object From Hierarchical Collection Pin
SledgeHammer019-May-12 13:11
SledgeHammer019-May-12 13:11 
GeneralRe: Remove Object From Hierarchical Collection Pin
Peter_in_27809-May-12 13:34
professionalPeter_in_27809-May-12 13:34 
GeneralMessage Removed Pin
9-May-12 13:43
SledgeHammer019-May-12 13:43 
GeneralRe: Remove Object From Hierarchical Collection Pin
Peter_in_27809-May-12 13:49
professionalPeter_in_27809-May-12 13:49 
QuestionGE PLC and C# Pin
Member 89517469-May-12 9:37
Member 89517469-May-12 9:37 
AnswerRe: GE PLC and C# Pin
Dave Kreskowiak9-May-12 10:24
mveDave Kreskowiak9-May-12 10:24 
QuestionIs it possible to export the Chart control as well as Gridview data to Excel format. Pin
ChandrakanthGaddam9-May-12 5:54
ChandrakanthGaddam9-May-12 5:54 
AnswerRe: Is it possible to export the Chart control as well as Gridview data to Excel format. Pin
Sandeep Mewara9-May-12 7:16
mveSandeep Mewara9-May-12 7:16 
GeneralRe: Is it possible to export the Chart control as well as Gridview data to Excel format. Pin
ChandrakanthGaddam9-May-12 10:35
ChandrakanthGaddam9-May-12 10:35 
GeneralRe: Is it possible to export the Chart control as well as Gridview data to Excel format. Pin
Sandeep Mewara9-May-12 18:58
mveSandeep Mewara9-May-12 18:58 
QuestionNeed help Pin
Member 89504289-May-12 4:48
Member 89504289-May-12 4:48 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.