how to find child nodes at root node [TreeView]

前端 未结 3 1295
野趣味
野趣味 2021-01-01 01:05
 ROOT
      A 
        B
          C 
            D 
              E
        T
      F
      G
        X

I want to find E Node\'s parent nodes(it i

3条回答
  •  旧巷少年郎
    2021-01-01 01:57

    I'm curious, since this is tagged as a WebForm, why Microsoft's FindNode method was not suggested. It is compatible from v2.0 up to now (currently v4.5.2).

    Does that not work here?

    From Microsoft's MSDN:

    Use the FindNode method to get a node from the TreeView control at the specified value path. The value path contains a delimiter-separated list of node values that form a path from the root node to the current node. Each node stores its value path in the ValuePath property. The PathSeparator property specifies the delimiter character that is used to separate the node values.

    Example:

    void Button_Click(Object sender, EventArgs e)
    {
    
      // Find the node specified by the user.
      TreeNode node = LinksTreeView.FindNode(Server.HtmlEncode(ValuePathText.Text));
    
      if (node != null)
      {
        // Indicate that the node was found.
        Message.Text = "The specified node (" + node.ValuePath + ") was found.";
      }
      else
      {
        // Indicate that the node is not in the TreeView control.
        Message.Text = "The specified node (" + ValuePathText.Text + ") is not in this TreeView control.";
      }
    
    }
    

提交回复
热议问题