Treeview

hi
I want to open a frame with help of a tree . Is it possible in java swing to call a frame with help of tree .
pls help me from appropriate code
thanks.

Note: This thread was originally posted in the [Java Programming|http://forums.sun.com/forum.jspa?forumID=31] forum, but moved to this forum for closer topic alignment.

Similar Messages

  • Object reference not set to an instance of an object in treeView

    Hello
    I wrote this code. I have this Error "Object reference not set to an instance of an object" on  " MessageBox.Show(tn.Text);"
    in " MaintreeView_BeforeSelect ".
    #region Remove BackColor of all treeview nodes
    private void ClearBackColor()
    TreeNodeCollection nodes = MaintreeView.Nodes;
    foreach (TreeNode tn in nodes)
    ClearRecursive(tn);
    private void ClearRecursive(TreeNode treeNode)
    foreach (TreeNode tn in treeNode.Nodes)
    tn.BackColor = Color.Empty;
    if(tn.IsSelected == true)
    tn.TreeView.SelectedNode = null;
    ClearRecursive(tn);
    #endregion
    private void MaintreeView_BeforeSelect(object sender, TreeViewCancelEventArgs e)
    ClearBackColor();
    TreeNode tn = MaintreeView.SelectedNode;
    if (tn != null)
    MessageBox.Show(tn.Text);
    if (tn.Level == 7)

    Hi ARZARE,
    I tested your code, it can show the tn.Text when in the rootnode.
    I suggest you putting the ClearBackColor() at the last of the BeforeSelect Event. Or this method will clear the selectNode.
    private void treeView1_BeforeSelect(object sender, TreeViewCancelEventArgs e)
    //ClearBackColor();
    TreeNode tn = this.treeView1.SelectedNode;
    if (tn != null)
    MessageBox.Show(tn.Text);
    ClearBackColor();
    If you have any other concern regarding this issue, please feel free to let me know.
    Best regards,
    Youjun Tang
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • How to get all checked items from TreeView in VC++ mfc

    void CPDlg::OnTreeClk(NMHDR *pNMHDR, LRESULT *pResult)
    NMTREEVIEW& nm = *(LPNMTREEVIEW)pNMHDR;
    // which item was selected?
    HTREEITEM hItem = m_columnTree.GetTreeCtrl().GetSelectedItem();
    temp = m_columnTree.GetItemText(hItem, 0);
    MessageBox(temp);
    if (!hItem) return;
    // the rest of processing code..
    I'm new in VC++ .
    this code gives only current selected item . but i need to get all checked items from treeView.
    kindly help me..

    no not unchecked .. the all check box's gone from tree view. which means Treeview without check box.
    finally i tried SetCheck 
    void CPracticesDlg::OnSelchangedTreectrl(NMHDR* pNMHDR, LRESULT* pResult)
    NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;
    // TODO: Add your control notification handler code here
    tree_state = 1;//changed
    HTREEITEM hItem = m_columnTree.GetTreeCtrl().GetSelectedItem();
    BOOL chk = m_columnTree.GetTreeCtrl().GetCheck(hItem);
    if (chk == TRUE)
    HTREEITEM hmyItem = m_columnTree.GetTreeCtrl().GetSelectedItem();
    // Check all of the children of hmyItem.
    if (m_columnTree.GetTreeCtrl().ItemHasChildren(hmyItem))
    HTREEITEM hNextItem;
    HTREEITEM hChildItem = m_columnTree.GetTreeCtrl().GetChildItem(hmyItem);
    while (hChildItem != NULL)
    hNextItem = m_columnTree.GetTreeCtrl().GetNextItem(hChildItem, TVGN_NEXT);
    m_columnTree.GetTreeCtrl().SetCheck(hChildItem, 1);
    hChildItem = hNextItem;
    else
    HTREEITEM hmyItem = m_columnTree.GetTreeCtrl().GetSelectedItem();
    // Uncheck all of the children of hmyItem.
    if (m_columnTree.GetTreeCtrl().ItemHasChildren(hmyItem))
    HTREEITEM hNextItem;
    HTREEITEM hChildItem = m_columnTree.GetTreeCtrl().GetChildItem(hmyItem);
    while (hChildItem != NULL)
    hNextItem = m_columnTree.GetTreeCtrl().GetNextItem(hChildItem, TVGN_NEXT);
    m_columnTree.GetTreeCtrl().SetCheck(hChildItem, 0);
    hChildItem = hNextItem;
    code works good . but here is i think small problem . i cant find it.
    when i click the root node it goes to checked state but not child node. again i click same root node it goes to unchecked state but all child's are goes to checked state.
    help me. here what is the problem?

  • Creating a TreeView using an SQL data source

    Hello and how is everyone. I have been coding in Java Windows services and console applications for a couple of years and now I want to start working on some Java Server Pages. I have been reading up on JSP and JSTL. What I want to do is query an SQL database and bring the data into my jsp page and display the data using a TreeView. Can someone help out ? Thanks :)

    If you want a tree component on a web page, you will have to use html/javascript to do that.
    You can't use swing components in an html page.
    Take a look around at javascript tree components (there are several around the net). You then have to write your jsp to generate the correct javascript code to populate that component.
    Obviously it all depends on the javascript component that you decide on to display the tree.
    Hope this helps,
    evnafets

  • How to blink TreeView Nodes based on condition c#

    suppose i am populating my tree view with data from database and i want to blink those nodes which has a specific data. now guide me with code how can i efficiently blink multiple tree view nodes  based on condition in winform application.

    Hi Mou_kolkata,
    >> anyone can give me small working code for tree node blinking
    Thank Armin for the details about blinking TreeView Nodes.
    For a simple demo to blink TreeView nodes, you could refer the link below:
    # Treeview control - How to make a node blink?
    https://social.msdn.microsoft.com/Forums/en-US/64e7a4d7-3098-4370-990f-390cb3a640a1/treeview-control-how-to-make-a-node-blink
    If you have issues when you blink Treeview nodes, please feel free to post a new thread in this forum, then you would get more help.
    Best Regards,
    Edward
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Opening file present in treeview by clicking on it within a table? I had created a table with a row and two columns. in one column i had dislayed treeview and want that if i click on the file in treeview it gets opened in other column. Can this happen?

    I also got a code in some website related to my problem but there are errors in this code that i am not able to understand can you correct those errors:
    using System;
    using System.IO;
    using System.Collections;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Web;
    using System.Web.SessionState;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.HtmlControls;
    using Microsoft.Web.UI.WebControls;
    namespace shark.TreeView
    /// <summary>
    /// Summary description for DocTree.
    /// </summary>
    public class DocTree : System.Web.UI.Page
    protected Microsoft.Web.UI.WebControls.TreeView TreeCtrl;
    public DocTree()
    Page.Init += new System.EventHandler(Page_Init);
    private void Page_Load(object sender, System.EventArgs e)
    if ( ! this.IsPostBack )
    // add tree node "type" for folders and files
    string imgurl = "/shark/webctrl_client/1_0/Images/";
    TreeNodeType type;
    type = new TreeNodeType();
    type.Type = "folder";
    type.ImageUrl = imgurl + "folder.gif";
    type.ExpandedImageUrl = imgurl + "folderopen.gif";
    TreeCtrl.TreeNodeTypes.Add( type );
    type = new TreeNodeType();
    type.Type = "file";
    type.ImageUrl = imgurl + "html.gif";
    TreeCtrl.TreeNodeTypes.Add( type );
    // start the recursively load from our application root path
    // (we add the trailing "/" for a little substring trimming below)
    GetFolders( MapPath( "~/./" ), TreeCtrl.Nodes );
    // expand 3 levels of the tree
    TreeCtrl.ExpandLevel = 3;
    private void Page_Init(object sender, EventArgs e)
    InitializeComponent();
    // recursive method to load all folders and files into tree
    private void GetFolders( string path, TreeNodeCollection nodes )
    // add nodes for all directories (folders)
    string[] dirs = Directory.GetDirectories( path );
    foreach( string p in dirs )
    string dp = p.Substring( path.Length );
    if ( dp.StartsWith( "_v" ) )
    continue; // ignore frontpage (Vermeer Technology) folders
    nodes.Add( Node( "", p.Substring( path.Length ), "folder" ) );
    // add nodes for all files in this directory (folder)
    string[] files = Directory.GetFiles( path, "*.aspx" );
    foreach( string p in files )
    nodes.Add( Node( p, p.Substring( path.Length ), "file" ) );
    // add all subdirectories for each directory (recursive)
    for( int i = 0; i < nodes.Count; i++ )
    if ( nodes[ i ].Type == "folder" )
    GetFolders( dirs[ i ] + "\\", nodes[i ].Nodes );
    // create a TreeNode from the specified path, text and type
    private TreeNode Node( string path, string text, string type )
    TreeNode n = new TreeNode();
    n.Type = type;
    n.Text = text;
    if ( type == "file" )
    // strip off the physical application root portion of path
    string nav = "/" + path.Substring( MapPath( "/" ).Length );
    nav.Replace( '\\', '/' );
    n.NavigateUrl = nav;
    // set target if using FRAME/IFRAME
    n.Target="doc";
    return n;
    #region Web Form Designer generated code
    /// <summary>
    /// Required method for Designer support - do not modify
    /// the contents of this method with the code editor.
    /// </summary>
    private void InitializeComponent()
    this.Load += new System.EventHandler(this.Page_Load);
    #endregion
    and the design that i got on website for the code that i displayed just above it is
    <%@ Register TagPrefix="iewc" Namespace="Microsoft.Web.UI.WebControls" Assembly="Microsoft.Web.UI.WebControls" %>
    <%@ Page language="c#" Codebehind="DocTree.aspx.cs" AutoEventWireup="false" Inherits="shark.TreeView.DocTree" %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
    <HTML>
    <HEAD>
    <meta content="Microsoft Visual Studio 7.0" name="GENERATOR">
    <meta content="C#" name="CODE_LANGUAGE">
    <meta content="JavaScript (ECMAScript)" name="vs_defaultClientScript">
    <meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
    </HEAD>
    <body>
    <form id="DocTree" method="post" runat="server">
    <table height="100%" cellSpacing="0" cellPadding="8" border="0">
    <tr height="100%">
    <td vAlign="top">
    <iewc:treeview id="TreeCtrl" runat="server" SystemImagesPath="/shark/webctrl_client/1_0/treeimages/">
    </iewc:treeview>
    </td>
    <td vAlign="top" width="100%" height="100%">
    Click on any *.aspx page in the tree and it should load here <iframe id="doc" name="doc" frameBorder="yes" width="100%" scrolling="auto" height="100%">
    </iframe>
    </td>
    </tr>
    </table>
    </form>
    </body>
    </HTML>
    This is my code for viewing treeview but it is not expanding plz help me in this also
    using System;
    using System.Collections.Generic;
    using System.Configuration;
    using System.Data;
    using System.IO;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;
    using System.Media;
    using System.Drawing;
    using System.Drawing.Imaging;
    public partial class _Default : System.Web.UI.Page
    protected void Page_Load(object sender, EventArgs e)
    if (Page.IsPostBack == false)
    System.IO.DirectoryInfo RootDir = new System.IO.DirectoryInfo(Server.MapPath("~/Files"));
    // output the directory into a node
    TreeNode RootNode = OutputDirectory(RootDir, null);
    // add the output to the tree
    MyTree.Nodes.Add(RootNode);
    TreeNode OutputDirectory(System.IO.DirectoryInfo directory, TreeNode parentNode)
    // validate param
    if (directory == null) return null;
    // create a node for this directory
    TreeNode DirNode = new TreeNode(directory.Name);
    // get subdirectories of the current directory
    System.IO.DirectoryInfo[] SubDirectories = directory.GetDirectories();
    // OutputDirectory(SubDirectories[0], "Directories");
    // output each subdirectory
    for (int DirectoryCount = 0; DirectoryCount < SubDirectories.Length; DirectoryCount++)
    OutputDirectory(SubDirectories[DirectoryCount], DirNode);
    // output the current directories file
    System.IO.FileInfo[] Files = directory.GetFiles();
    for (int FileCount = 0; FileCount < Files.Length; FileCount++)
    DirNode.ChildNodes.Add(new TreeNode(Files[FileCount].Name));
    } // if the parent node is null, return this node
    // otherwise add this node to the parent and return the parent
    if (parentNode == null)
    return DirNode;
    else
    parentNode.ChildNodes.Add(DirNode);
    return parentNode;
    This is my design
    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
    <!DOCTYPE html>
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
    <title></title>
    <style type="text/css">
    .auto-style2
    width: 412px;
    .auto-style3
    width: 174px;
    .auto-style4
    width: 743px;
    .auto-style5
    width: 506px;
    height: 226px;
    </style>
    </head>
    <body>
    <form id="form1" method="post" runat="server">
    <table align:"center" class="auto-style4" border="1" style="table-layout: fixed; border-spacing: 1px">
    <tr>
    <td class="auto-style3">
    <br />
    <br />
    <br />
    <br />
    </td>
    <td class="auto-style2">
    <br />
    <br />
    <br />
    <br />
    </td>
    </tr>
    <tr>
    <td class="auto-style3" valign="top">
    <asp:TreeView Id="MyTree" PathSeparator = "|" ExpandDepth="0" runat="server" ImageSet="Arrows" AutoGenerateDataBindings="False">
    <SelectedNodeStyle Font-Underline="True" HorizontalPadding="0px" VerticalPadding="0px" ForeColor="#5555DD"></SelectedNodeStyle>
    <NodeStyle VerticalPadding="0px" Font-Names="Tahoma" Font-Size="10pt" HorizontalPadding="5px" ForeColor="#000000" NodeSpacing="0px"></NodeStyle>
    <ParentNodeStyle Font-Bold="False" />
    <HoverNodeStyle Font-Underline="True" ForeColor="#5555DD"></HoverNodeStyle>
    </asp:TreeView>
    </td>
    <td class="auto-style2">
    <base target="_blank" /> <iframe frameborder="0" scrolling="yes" marginheight="0" marginwidth="0"
    src="" class="auto-style5"></iframe>
    </td>
    </tr>
    </table>
    </form>
    </body>
    </html>

    Hi meghage,
    From your code, it is a WebForm project.
    This forum is to discuss problems of Windows Forms. Your question is not related to the topic of this forum.
    You can consider posting it in asp.net forum for supports . Thanks.
    ASP.NET: http://forums.asp.net
    Regards,
    Youjun Tang
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Access 2013 64-bit Treeview Alternative

    I have a code snippets application that I wrote in Access and recently migrated to 64-bit version of Office 2013.
    In addition to the Snippets being searchable, I also had them organized in a hierarchy (i.e., treeview) for browsing.  With expandable nodes for such things as TSQL, CSS, etc.
    I don't really see much point in complaining about Microsoft's short-sightedness in eliminating the treeview control, so I'm just going to pose a question that highlight my basic problem:
    What can I use in 2013 Access 64-bit to display the hierarchical organization of my data ??
    Look forward to your suggestions.

    Hi,
    I'm marking the reply as answer as there has been no update for a couple of days.
    If you come back to find it doesn't work for you, please reply to us and unmark the answer.
    Thanks
    George Zhao
    Forum Support
    Come back and mark the replies as answers if they help and unmark them if they provide no help.
    If you have any feedback on our support, please click "[email protected]"

  • The Treeview navigation seems to have broken my intranet .

    Hmmmmmmm  sometimes issues with SharePoint are like buses - earlier I found that could not open any word documents until installed Office 2010 SP2 32-bit but that is not why I am here :-( .
    I am developing a new intranet for a client and am testing out a load of OOTB features to see which ones will best meet requirements we have defined,  ahead of a live deployment.  This led me to the Treeview widget to see if it will help with navigation.
      I enabled it on the top level home site which worked but showed way too much information for my users. Hence, I went  over to a member of the team to see what there view looks like ( without SC admin / site owner privileges).
    He got this error ( see below) - turns our everyone does now include me ( after a refresh) !  Ouch. Now
    this maybe due to our thin client environment .  However this very strange. The only person who has ever changed the master page is me earlier this week when I enabled the breadcrumb but we have all been using this for days - have never
    touched the control shown in error.   I will see if anybody in the IT team hasn't been fiddling with the farm but I suspect I am the cause of this disaster ......
    Now, I need to remove the treeview feature via settings but I don't seem to be able to navigate to / _settings. 
    I can access the site via SharePoint designer 
    I created a replica site albeit unpopulated on my laptop so I can copy untouched  master pages  if needed. 
    I just need to get this fixed asap!!!!
    Daniel

    Hi skcooke
    As in Ribbon bar ->  admin page button - doh! Done and home site is now accessible - thanks. I will try that next time rather than going directly to the browser and then _settings.aspx. Hmmm will try the treeview again but not when in a hurry
    to leave the office lol..

  • Issue in treeview control along with page viewer web part showing the sub sites from MMS

    hi,
    Am having a treeview control populates  with values from  MMS - Managed Metadata Service.
    [ Products ]
    ----->ms office 
                ----->word
                ----->excel
                 ---->powerpoint
    -------->Collaboration
                     ---->   sharepoint 2003
                     ---->  moss 2007
                     ----> sp 2010
                     -----> lync
     all these  values excel, word, powerpoint are sub sites created under ms-office site collection.
    and  sharepoint 2003, mos 2007, sp 2010, sp 2013 are  sub sites created under collaboration.
    now, on the page load, end user clicks on word and he should navigate to the  sub site "wordsite"  and it should show the home page of word sub site.
    we have created a  page viewer web part and  assigned the url property of the page viewer to the sub site url.
    but the issue is, when end user clicked  on the child node "powerpoint", the  page did a Post Back and treeview control immediately collpased and it shows the Products [top level - parent node] only.
    Am unable to set the current selected value- ie  here its excel and show the excel node in the trewview.
    how can i get this child tree node as the selected node.
    help is  highly appreciated!

    Check if below can help
    http://thechriskent.com/2012/05/09/changing-the-default-expansion-of-metadata-navigation-on-initial-page-load/

  • Memory Leak issue with TreeView

    Hi,
    I get Memory Leaks in the TreeView, if I open the stage which contains the TreeView several times.
    Everytime I open the stage, I clear the TreeView and populate it with new items.
    However there are leaks.
    I think this is a bug. But maybe my code is wrong and someone could comment on this issue.
    See this test case:
    i < 10: 5854 KB
    i < 100: 35944 KB
    i < 200: 64515 KB
    import javafx.application.Application;
    import javafx.event.EventHandler;
    import javafx.scene.Scene;
    import javafx.scene.control.TreeItem;
    import javafx.scene.control.TreeView;
    import javafx.scene.layout.VBox;
    import javafx.stage.Stage;
    import javafx.stage.WindowEvent;
    public class TestApp3 extends Application {
        public static void main(String[] args) throws Exception {
            launch(args);
        public void start(final Stage stage) throws Exception {
            VBox root = new VBox();
            SubStage subStage = new SubStage();
            for (int i = 0; i < 10; i++) {
                subStage.show();
                subStage.hide();
            System.gc();
            System.out.println((Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) / 1024 + " KB");
            Scene scene = new Scene(root);
            stage.setScene(scene);
            stage.show();
        private class SubStage extends Stage {
            public SubStage() {
                TreeView<String> treeView = new TreeView<String>();
                final TreeItem<String> rootNode = new TreeItem<String>("Root");
                treeView.setRoot(rootNode);
                setOnShowing(new EventHandler<WindowEvent>() {
                    @Override
                    public void handle(WindowEvent windowEvent) {
                        rootNode.getChildren().clear();
                        rootNode.getChildren().add(new TreeItem<String>("Item"));
                Scene scene = new Scene(treeView);
                setScene(scene);
    }Edited by: csh on 07.09.2012 06:14
    Edited by: csh on 07.09.2012 06:14

    Hi. If You replace
        rootNode.getChildren().clear();
        rootNode.getChildren().add(new TreeItem<String>("Item"));
      with:
         rootNode.getChildren().setAll( new TreeItem<String>("Item"));
    You will get the following:
    i < 10: 2881 KB
    i < 100: 3341 KB
    I <200: 3478 KB

  • How to move node in treeView using two buttons ?

    Hello ,
    Am starter , and am working on a Winforms application.
    I browse an XML file , then I populate treeview in my interface. I want to move selected node in the two sens ( up and down)  using two button ( so not with events , normal drag and drop with mouse ) .
    - I select the nod 
    - I click on the up button , then the node take the new place ( something like , drop and insert maybe )
    I don't know if is possible to affect this events to button or they are another way to do this 
    this is my code concerning populating treeView :
    private void browseSourceFileBtn_Click(object sender, EventArgs e)
    var openSourceFile = openSourceFileDialog.ShowDialog();
    if (openSourceFile == DialogResult.OK)
    fichierSourcePath.Text = openSourceFileDialog.FileName;
    // Connect the XML FILE DATABASE to the application interface
    private void button1_Click(object sender, EventArgs e)
    if (openSourceFileDialog.FileName == String.Empty)
    MessageBox.Show("u should open a file", "Erreur de chargement", MessageBoxButtons.OK, MessageBoxIcon.Error);
    else
    try
    MessageBox.Show("plz wait ");
    statusLabel.Text = "Début de chargement du fichier";
    var doc = new XmlDocument();
    doc.Load(openSourceFileDialog.FileName);
    sourceTreeView.Nodes.Clear();
    var rootNode = new TreeNode(doc.DocumentElement.Name);
    sourceTreeView.Nodes.Add(rootNode);
    sourceTreeView.CheckBoxes = true;
    sourceTreeView.AllowDrop = true;
    DateTime starteTime = DateTime.Now;
    BuildNode(doc.DocumentElement, rootNode);
    DateTime endTime = DateTime.Now;
    TimeSpan duree = endTime - starteTime;
    sourceTreeView.ExpandAll();
    sourceTreeView.Nodes[0].EnsureVisible();
    string chargementTemps = "" + duree.Minutes + "min : " + duree.Seconds + "s : " + duree.Milliseconds + "ms";
    statusLabel.Text = "Chargement effectué avec succés en :" + chargementTemps;
    catch (Exception)
    sourceTreeView.Nodes.Clear();
    statusLabel.Text = "Echec de chargement";
    thanks u a lot 

    Hi Nico68er,
    According to your description, you'd like to move up or down the node in TreeView.
    By reseraching, I found this post in StackOverFlow is similar with your issue.http://stackoverflow.com/questions/2203975/move-node-in-tree-up-or-down
    From this answer.
    You can use the following extensions
    public static class Extensions
    public static void MoveUp(this TreeNode node)
    TreeNode parent = node.Parent;
    TreeView view = node.TreeView;
    if (parent != null)
    int index = parent.Nodes.IndexOf(node);
    if (index > 0)
    parent.Nodes.RemoveAt(index);
    parent.Nodes.Insert(index - 1, node);
    else if (node.TreeView.Nodes.Contains(node)) //root node
    int index = view.Nodes.IndexOf(node);
    if (index > 0)
    view.Nodes.RemoveAt(index);
    view.Nodes.Insert(index - 1, node);
    public static void MoveDown(this TreeNode node)
    TreeNode parent = node.Parent;
    TreeView view = node.TreeView;
    if (parent != null)
    int index = parent.Nodes.IndexOf(node);
    if (index < parent.Nodes.Count -1)
    parent.Nodes.RemoveAt(index);
    parent.Nodes.Insert(index + 1, node);
    else if (view != null && view.Nodes.Contains(node)) //root node
    int index = view.Nodes.IndexOf(node);
    if (index < view.Nodes.Count - 1)
    view.Nodes.RemoveAt(index);
    view.Nodes.Insert(index + 1, node);
    Child nodes will follow their parents.
    You could use this class in your program.
    If you want to move the node up. Call the Extensions.MoveUp(this.treeView1.SelectNode)
    private void button1_Click(object sender, EventArgs e)
                if (this.treeView1.SelectedNode != null)
                    Extensions.MoveUp(this.treeView1.SelectedNode);
    If you have any other concern regarding this issue, please feel free to let me know.
    Best regards,
    Youjun Tang
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • How can i loop over treeview selected nodes and then to delete each node if it's a directory or a file ?

    I have this code:
    if (s == "file")
    file = false;
    for (int i = 0; i < treeViewMS1.SelectedNodes.Count; i++)
    DeleteFile(treeViewMS1.SelectedNode.FullPath, file);
    I know it's a file and it is working if it's a single file.
    On the treeView i click on a file right click in the menu i select delete and it's doing the line:
    DeleteFile(treeViewMS1.SelectedNode.FullPath, file);
    And it's working no problems.
    But i want to do that if i selected some files togeather multiple selection then to delete each file.
    So i added the FOR loop but then how do i delete from the SelectedNodes each node ?
    The treeView SelectedNodes dosen't have FullPath like SelectedNode also doing SelectedNodes[i] dosen't have the FullPath property.
    Same as for if i want to delete a single directory or multiple selected directories:
    This is the continue of the code if it"s not a "file" (else) it's null i know it's a directory and doing:
    else
    file = true;
    RemoveDirectoriesRecursive(treeViewMS1.SelectedNode, treeViewMS1.SelectedNode.FullPath);
    Also here i'm using SelectedNode but if i marked multiple directories then i how do i loop over the SelectedNodes and send each SelectedNode to the RemoveDirectoriesRecrusive method ?
    My problem is how to loop over SelectedNode(multiple selection of files/directories) and send each selected file/directory to it's method like i'm doing now ?

    foreach (TreeNode n in treeViewMS1.SelectedNodes)
    // Remove everything associated with TreeNode n here
    I don't think it's any harder than that, is it?
    If you can multi-select both an item and one of its descendents in the tree, then you'll have the situation that you may have deleted the parent folder and all of its children by the time you get around to deleting the descendent.  But that's not such
    a big deal.  A file can get deleted externally to your program too - so you'll just have to deal with it having been deleted already (or externally) when you get around to deleting it yourself.

  • Using TreeViewer and creating a pop-up menu?

    I am using Eclipse Ganymede(3.1?) to write my program. This project has multiple parts(most issues/progress can be tracked back in java-forums.org) and I am trying to get the last bit of my GUI finished. I have a TreeViewer that displays on top of a composite display(not a component) which is why I haven't been able to find a solution that works for me. My tree is interactive(double click nodes to expand, deepest nodes open up an editor view, auto refresh new nodes/deletes etc) and I'm trying to make a pop-up menu appear on right click that would give all the options the File menu gives. I haven't been able to find a work around on how to attach the menu since my TreeViewer is based on a composite instead of a component there is no where to attach the menu. I have been working on this one issue for a week with no progress and am at the point where I'm tempted to rewrite my entire project using JPanel and JPanes and Tree but I REALLY don't want to have to do this. This is my createPartControl method with the relevent sections.
    public void createPartControl(final Composite parent) {
    //          final Tree tree = new Tree(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
              treeViewer = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
    //          treeViewer = new TreeViewer(tree);
              treeViewer.setContentProvider(new ViewContentProvider());
              treeViewer.setLabelProvider(new ViewLabelProvider());
              treeViewer.setInput(createDummyModel());
    //Double click listener
              treeViewer.addOpenListener(new IOpenListener() {
                   public void open(final OpenEvent event) {
                        //double click expands/shrinks nodes, opens up target editors
    //Selection listener
              treeViewer.addSelectionChangedListener(new ISelectionChangedListener() {
                      public void selectionChanged(SelectionChangedEvent event) {
                           final IActionBars bars = getViewSite().getActionBars();
                           selObj = ((IStructuredSelection) event.getSelection()).getFirstElement();                      
                                      //...outputs selection to status bar
    //Mouse listener
              treeViewer.getTree().addMouseListener(new MouseAdapter(){
                 public void mouseUp(MouseEvent event){
                      if(event.button==3){         //right click
                           System.out.println(event.getSource());        //Tree{ }
                           System.out.println(event.display);             //org.eclipse.swt.widgets.Display@1e328e0
                           if(selObj instanceof Server){
                                System.out.println(treeViewer.getControl().toString());          //Same as event.getSource()
                                               /*code to have menu appear goes here*/
                                System.out.println("Server Menu");
                                //Delete Server
                                //Edit Server
                                //View Properties
         }Does anybody know a way I can attach a popup menu to the node I click on or if it's possible(and if so how would I go about) attaching it to the display beneath the TreeViewer and somehow setting the focus or making the popup a heavy component so it would appear on top?
    P.S there's alot more superfluous code in the listeners but they don't pertain to this so I removed them.

    Can anyone confirm that what I'm trying to do is not possible? I found this link which states an SWT bug of the header not being a control so it become unattachable. http://dev.eclipse.org/newslists/news.eclipse.platform.swt/msg38040.html
    Any truth in this and if so where can I track progress of the bug?

  • Tree (TreeView) in Applet

    Hello,
    could you please give a hint how I can use TreeView in applets?
    Actually I need a code example of how to add a TreeView component to an applet.

    Let me be your google agent. Rather than have you waste your time typing in a web search query, you can just click on this link:
    http://www.google.com/search?hl=en&q=applet+TreeView+example

  • Problem in inserting a node in Treeview.

    Hi all,
    I'm having a problem in inserting a node in the
    treeview always it appends in the end of the
    sibling.
    Basically on double clicking of any node in the
    treeview should create a copy of the double clicked
    node and just insert the copy of the doubleclicked
    node next to the doubleclicked node instead at the end of the sibling.
    if i do this it will to the end of all the siblings.
    copyObject = l_SelectedNode.Clone();
    copyObject.Parent = l_SelectedNode.Parent;
    instead of next to it.
    I am trying something like this:
    RootNode
    |
    ---CHILD Sibling Node1
    | |
    ----GrandChild1Sibling1
    | |
    ---GrandChild1Sibling2 <<-- double clicking
    (GrandChild1Sibling2)
    | |
    <<-- it must add
    (GrandChild1Sibling2_copy)
    ---GrandChild1Sibling3
    | |
    ---GrandChild1Sibling4
    | << -- But it is adding a copy here
    at the end of all sibbling..
    |
    ---CHILD Sibling Node2
    | |
    -------GrandChild2Sibling1
    | |
    ------GrandChild2Sibling2
    | |
    ------GrandChild2Sibling3
    | |
    ------GrandChild2Sibling4
    |
    i am doing GrandChild1Sibling2_copy.parent =
    GrandChild1Sibling2.Parent;
    it will always add in the end of all the sibling as
    (GrandChild1Sibling5_copy) instead of next to
    (GrandChild1Sibling3_copy) Just below the GrandChild1Sibling2.
    Is there any simple soln or any ordering factor which i should look for.
    Thanx in advance...
    Regards,
    -Prasad

    Hello,
    Check the following link.
    SQL error 1653
    Hope it helps in solving your problem.
    Thanks and Regards,
    Sachin

  • Treeview Add Child to Parent Node Without Creating a New Parent

    I have a treeview setup with a HierarchicalDataTemplate in my XAML as follows:
    <TreeView Grid.Column="1" Grid.Row="0" ItemsSource="{Binding treeViewObsCollection}">
    <TreeView.ItemTemplate>
    <HierarchicalDataTemplate ItemsSource="{Binding mainNodes}">
    <TextBlock Text="{Binding topNodeName}"/>
    <HierarchicalDataTemplate.ItemTemplate>
    <DataTemplate>
    <TextBlock Text="{Binding subItemName}"></TextBlock>
    </DataTemplate>
    </HierarchicalDataTemplate.ItemTemplate>
    </HierarchicalDataTemplate>
    </TreeView.ItemTemplate>
    </TreeView>
    Here is the ViewModel which is set as the Data Context for the XAML File.
    class AdvancedErrorCalculationViewModel : ViewModelBase
    static ObservableCollection<TreeViewClass> _treeViewObsCollection = new ObservableCollection<TreeViewClass>();
    public static ObservableCollection<TreeViewClass> treeViewObsCollection { get { return _treeViewObsCollection; } }
    public class TreeViewClass : ViewModelBase
    public TreeViewClass(string passedTopNodeName)
    topNodeName = passedTopNodeName;
    mainNodes = new ObservableCollection<TreeViewSubItems>();
    public string topNodeName
    get { return this.GetValue<string>(); }
    set { this.SetValue(value); }
    public ObservableCollection<TreeViewSubItems> mainNodes { get; private set; }
    public class TreeViewSubItems : ViewModelBase
    public TreeViewSubItems(string passedSubItemName, string passedSubItemJobStatus)
    subItemName = passedSubItemName;
    subItemJobStatus = passedSubItemJobStatus;
    public string subItemName
    get { return this.GetValue<string>(); }
    set { this.SetValue(value); }
    public string subItemJobStatus
    get { return this.GetValue<string>(); }
    set { this.SetValue(value); }
    public static void AddTreeViewItems(string passedTopNodeName, string passedChildItemName, string passedChildItemJobStatus)
    treeViewObsCollection.Add(new TreeViewClass(passedTopNodeName)
    mainNodes =
    new TreeViewSubItems(passedChildItemName, passedChildItemJobStatus)
    The problem lies with the AddTreeViewItems method
    seen above. Currently, if I call the method by let's say:
    AdvancedErrorCalculationViewModel.AddTreeViewItems("Parent","Child 1", "Completed");
    it creates the parent and child nodes just fine. No issues there.
    However, if I call the method again with the same Parent name but a different Child; for example: 
    AdvancedErrorCalculationViewModel.AddTreeViewItems("Parent","Child 2", "Completed");
    It creates a new Parent node with a child node Child 2 instead. Thus, I have something like this:
    - Parent
    - Child 1
    - Parent
    - Child 2
    I would like to modify this function so that if the parent name is the same, the child node should belong under the previous Parent instead
    of under a new Parent node. Something like this:
    - Parent
    - Child 1
    - Child 2
    Could anyone help me modify my code to detect if the Parent node exists in the observablecollection already and if so, place the child node under the existing parent? The main problem I am facing is trying to add items to a previously created observable collection
    with an existing hierarchy because I don't know how to access the previous observable collection anymore. Help me with this please.
    Thanks in advance. :)

    You need to try and find an existing entry and if it's there add the child to that instead.
    I notice you're  a student and I guess this is probably an assignment.
    By the way.
    I suggest you work on the name of your collections and classes there.
    EG A class should be singular but way more meaningfull than treeviewsubitem.
    Anyhow, finding the top node could be done using linq.  Since you can get none, SingleOrDefault is the method to use.
    Thus something like:
    TreeViewClass tvc = treeViewObsCollection.Where
    (x=>x.Title == passedTopNodeName).SingleOrDefault();
    Will give you tvc null or the qualifying entry.
    If it's null, do what you have now.
    If it's not then add the child item to tvc.
    tvc is a reference to the TreeViewClass you have in that collection.
    Please don't forget to upvote posts which you like and mark those which answer your question.
    My latest Technet article - Dynamic XAML

Maybe you are looking for