CodeVerge.Net Beta


   Explore    Item Entry    Members      Register  Login  
NEWSGROUP
.NET
Algorithms-Data Structures
Asp.Net
C Plus Plus
CSharp
Database
HTML
Javascript
Linq
Other
Regular Expressions
VB.Net
XML

Free Download:




Zone: > NEWSGROUP > Asp.Net Forum > windows_hosting.hosting_open_forum Tags:
Item Type: NewsGroup Date Entered: 11/28/2004 8:52:46 PM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
(NR, 0)
XPoints: N/A Replies: 1 Views: 17 Favorited: 0 Favorite
Can Reply:  No Members Can Edit: No Online: Yes
2 Items, 1 Pages 1 |< << Go >> >|
Eol
Asp.Net User
Moving TreeNodes11/28/2004 8:52:46 PM

0/0

Hello,

I have some code written that works with a TreeView control, which is intended to allow you to re-order programatically created nodes.

The treeview itself is not bound to any XML or datasource, but all of its nodes are created through NodeX.ChildNodes.Add(NodeObject)


While the add & remove functionality work fine, moving it up/down the tree is giving me some problems.

Here is my code for that process:

private void LayoutMoveNodeUp(object sender, EventArgs e)
{
TreeNode CurNode = LayoutView.SelectedNode;
TreeNode ParentNode;

if (CurNode != null && CurNode.Depth != 0)
{
int idx;
ParentNode = CurNode.Parent;

idx = ParentNode.ChildNodes.IndexOf(CurNode);
if (idx > 0)
{
ParentNode.ChildNodes.AddAt(idx - 1, CurNode);
ParentNode.ChildNodes.RemoveAt(idx+1);
}
}
}

Now, this does get the node to move up the tree; however, after postback the newly moved node is in the "first column"; not under its parent like it should be. However, after making another postback by either clicking on the node, or some other object; it corrects itself.

Here is sort of a visual explaination of what happens:

Beginning....

Root
|
+-- ChildA1
+--Child B1
+--Child B2

After clicking on the "move up"

Root
|
+-- ChildA1
+-- ChildB2
+--ChildB1

And after a postback...

Root
|
+--ChildA1
+--Child B2
+--Child B1

Does anyone know if there is some "redraw" function or method that I'm supposed to call after messing with a node like this?

Thanks,

Craig
Fredrik N
Asp.Net User
Re: Moving TreeNodes11/29/2004 8:05:32 AM

0/0

It's probably a bug, I think you should report this to the MSDN Feedback Center.

It will work if you clear all the nodes in the TreeView control after you have moved the node, and then create a new node where you add all your ParentNode childs into the new parent node, and then add the parent node to the TreeView

The following code is the workaround:


protected void Button1_Click(object sender, EventArgs e)
{
TreeNode CurNode = TreeView1.SelectedNode;
TreeNode ParentNode;

if (CurNode != null && CurNode.Depth != 0)
{
int idx;
ParentNode = CurNode.Parent;

idx = ParentNode.ChildNodes.IndexOf(CurNode);

if (idx > 0)
{
ParentNode.ChildNodes.AddAt(idx - 1, CurNode);
ParentNode.ChildNodes.RemoveAt(idx+1);
}


//Workaround
TreeView1.Nodes.Clear();

TreeNode root = new TreeNode(ParentNode.Text);
root.Expand();

foreach( TreeNode child in ParentNode.ChildNodes)
{
root.ChildNodes.Add(child);
}

TreeView1.Nodes.Add(root);
//Workaround


}
}


/Fredrik Norm?n NSQUARED2
Microsoft MVP, MCSD, MCAD, MCT

Cornerstone

My Blog, ASP.Net 2.0 etc
2 Items, 1 Pages 1 |< << Go >> >|


Free Download:

Books:
Using Software in Qualitative Research: A Step-by-step Guide Authors: Ann Lewins, Christina Silver, Pages: 288, Published: 2007
The NVivo Qualitative Project Book Authors: Patricia Bazeley, Lyn Richards, Pages: 199, Published: 2000
Nearest Neighbor Search: A Database Perspective Authors: Apostolos N. Papadopoulos, Yannis Manolopoulos, Pages: 170, Published: 2005
Database And Expert Systems Applications: 15th International Conference, DEXA 2004, Zaragoza, Spain, August 30-September 3, 2004 : Proceedings Authors: Fernando Galindo, Makoto Takizawa, Roland Traunmüller, Pages: 972, Published: 2004
Qualitative Data Analysis with NVivo Authors: Pat Bazeley, Patricia Bazeley, Pages: 217, Published: 2007
Algorithms--ESA 2003: 11th Annual European Symposium, Budapest, Hungary, September 16-19, 2003 : Proceedings Authors: Giuseppe Di Battista, Uri Zwick, Pages: 790, Published: 2003
Algorithms and Computation: 4th International Symposium, ISAAC '93, Hong Kong, December 1993 : Proceedings Authors: Kam Wing Ng, Pages: 542, Published: 1993
Health Promotion: Planning and Strategies Authors: Keith Tones, Jackie Green, Pages: 376, Published: 2004
Using NVivo in Qualitative Research Authors: Lyn Richards, Pages: 240, Published: 1999

Web:
Moving TreeNode Sample Moving a TreeNode from one parent node to another inside of a TreeView was always easy in the past, but, oddly, it is not so obvious in the new .Net world. ...
Copy Tree Nodes Instead of Moving - Ext JS Forums Copy Tree Nodes Instead of Moving Ext 1.x: Help. ... Is it possible to create a copy of a tree node to be dropped into another tree? ...
Move treenodes up and down the tree - .NET C# Move treenodes up and down the tree. Get answers to your questions in our .NET C# forum.
Move treenodes up and down the tree - Application Development Forum Move treenodes up and down the tree CSharp. ... This is a discussion on Move treenodes up and down the tree within the CSharp forums in ...
moving from free to tree nodes - QSR Forum moving from free to tree nodes. Options V ... that started out as free nodes would fit better as a child under a parent in the tree nodes. ...
Manipulating Tree Nodes The above code will move the tree node with the node id "Network Database" under the parent node with id "Events". The node will be moved to first (0) ...
Moving a TreeNode in a TreeView - MSDN Forums Moving a TreeNode in a TreeView Thread Starter: Gohalien Started: 15 Jun 2007 3: 22 PM UTC Replies: 4. Thread Information. Most Recent Reply: 15 Jun 2007, ...
Tranglos Software: KeyNote: Known bugs and limitations (This does not apply when setting a color for a specigic tree node uysing the ... When moving tree nodes with checkboxes, the state of the checkbox is lost ...
XUL Drag Drop Tree + Adding / Deleting Nodes + Move up / Move down ... You can drag/drap individual tree nodes on other nodes, which will become childs of that node. Move nodes up or down with the context menu - right click on ...
Swap Tree Nodes Talk about Swap Tree Nodes. ... A similar technique can be used for for moving down: insert it one lower. But note that you have to call ...




Search This Site:










dnnstore forums problems help........

authentication tickets and session variables ?

upgrading from dnn 2.1.2 to dnn 3.0.5

starter kit if .net version 2.0

using a remote test server and not localhost

links_list page jumps to item's external link

hi - a sql security question - and a suggestion for f.a.q.

documents module tracking (?)

alignment of solpart menu

dnn 3.0.12 + htmlinputfile control

web service problems

theming for custom controls in asp.net 2.0

generation of designer file failed

unable to add buttons into a loginview

access to path denied, missing logconfig.xml.resources file

security with client-side callbacks

admin options to add/edit module and tabs at the top of the website appears when not logged in as admin/host

specified cast is not valid.

suggestion: webcast presentation when dnn 2.0 is released

can i change the name of a child portal?

bug: 3.0.6 - tabbing through user registration fields

masterpage ,asp.net 2.0

commercial portals derived from dnn

newbie: developing custom module and...

padnninstaller issue

server purposing webcast dec 7th

ionsimplechat

breadcrumb problem (2.1.2)

issue running aspnet_regsql successfully

requires sql, iis, .net framework but i have those already

 
All Times Are GMT