Share via


TreeNode Oluşturucular

Tanım

TreeNode sınıfının yeni bir örneğini başlatır.

Aşırı Yüklemeler

TreeNode()

Metin veya değer olmadan sınıfın TreeNode yeni bir örneğini başlatır.

TreeNode(String)

Belirtilen metni kullanarak sınıfının yeni bir örneğini TreeNode başlatır.

TreeNode(String, String)

Belirtilen metin ve değeri kullanarak sınıfının yeni bir örneğini TreeNode başlatır.

TreeNode(TreeView, Boolean)

Belirtilen sahibi kullanarak sınıfının yeni bir örneğini TreeNode başlatır.

TreeNode(String, String, String)

Belirtilen metin, değer ve görüntü URL'sini TreeNode kullanarak sınıfın yeni bir örneğini başlatır.

TreeNode(String, String, String, String, String)

Belirtilen metni, değeri, görüntü URL'sini TreeNode , gezinti URL'sini ve hedefi kullanarak sınıfın yeni bir örneğini başlatır.

TreeNode()

Metin veya değer olmadan sınıfın TreeNode yeni bir örneğini başlatır.

public:
 TreeNode();
public TreeNode ();
Public Sub New ()

Örnekler

Aşağıdaki kod örneği, denetime dinamik olarak bir düğüm eklemek için bu oluşturucunun TreeView nasıl kullanılacağını gösterir.


<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">

  void Page_Init(Object sender, EventArgs e)
  {
  
    if(!IsPostBack)
    {

      // Add the first tree to the TreeView control.
      CreateTree("Section 1");

      // Add the second tree to the TreeView control.
      CreateTree("Section 2");
    
    }

  }

  void CreateTree(String NodeText)
  {

    // Create the root node using the default constructor.
    TreeNode root = new TreeNode();
    root.Text = NodeText;

    // Use the ChildNodes property of the root TreeNode to add child nodes.
    // Create the node using the constructor that takes the text parameter.
    root.ChildNodes.Add(new TreeNode("Topic 1"));

    // Create the node using the constructor that takes the text and value parameters.
    root.ChildNodes.Add(new TreeNode("Topic 2", "Value 2"));

    // Create the node using the constructor that takes the text, value, 
    // and imageUrl parameters.
    root.ChildNodes.Add(new TreeNode("Topic 3", "Value 3", "Image1.jpg"));

    // Create the node using the constructor that takes the text, value, 
    // imageUrl, navigateUrl, and target parameters.
    root.ChildNodes.Add(new TreeNode("Topic 4", "Value 4", "Image1.jpg", "http://www.microsoft.com", "_blank"));

    // Add the root node to the Nodes collection of the TreeView control.
    DynamicTreeView.Nodes.Add(root);

  }

</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>TreeNode Constructor Example</title>
</head>
<body>
    <form id="form1" runat="server">
    
      <h3>TreeNode Constructor Example</h3>
      
      <asp:TreeView id="DynamicTreeView"
         EnableClientScript="false"
         ExpandDepth="2" 
         runat="server">
        
      </asp:TreeView>

    </form>
  </body>
</html>

<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">

  Sub Page_Init(ByVal sender As Object, ByVal e As EventArgs)

    If Not IsPostBack Then

      ' Add the first tree to the TreeView control.
      CreateTree("Section 1")

      ' Add the second tree to the TreeView control.
      CreateTree("Section 2")

    End If

  End Sub

  Sub CreateTree(ByVal NodeText As String)

    ' Create the root node using the default constructor.
    Dim root As TreeNode = New TreeNode
    root.Text = NodeText

    ' Use the ChildNodes property of the root TreeNode to add child nodes.
    ' Create the node using the constructor that takes the text parameter.
    root.ChildNodes.Add(New TreeNode("Topic 1"))

    ' Create the node using the constructor that takes the text and value parameters.
    root.ChildNodes.Add(New TreeNode("Topic 2", "Value 2"))

    ' Create the node using the constructor that takes the text, value, 
    ' and imageUrl parameters.
    root.ChildNodes.Add(New TreeNode("Topic 3", "Value 3", "Image1.jpg"))

    ' Create the node using the constructor that takes the text, value, 
    ' imageUrl, navigateUrl, and target parameters.
    root.ChildNodes.Add(New TreeNode("Topic 4", "Value 4", "Image1.jpg", "http://www.microsoft.com", "_blank"))

    ' Add the root node to the Nodes collection of the TreeView control.
    DynamicTreeView.Nodes.Add(root)

  End Sub

</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>TreeNode Constructor Example</title>
</head>
<body>
    <form id="form1" runat="server">
    
      <h3>TreeNode Constructor Example</h3>
      
      <asp:TreeView id="DynamicTreeView"
         EnableClientScript="false"
         ExpandDepth="2" 
         runat="server">
        
      </asp:TreeView>

    </form>
  </body>
</html>

Açıklamalar

Varsayılan değerleri kullanarak sınıfın TreeNode yeni bir örneğini başlatmak için bu oluşturucuyu kullanın.

Not

Bu oluşturucu kullanıldığında, nesnedeki TreeNode tüm özellikler varsayılan değerlerine ayarlanır. Nesneyi oluşturduktan sonra özellikleri gerektiği gibi ayarladığınızdan emin olun.

Ayrıca bkz.

Şunlara uygulanır

TreeNode(String)

Belirtilen metni kullanarak sınıfının yeni bir örneğini TreeNode başlatır.

public:
 TreeNode(System::String ^ text);
public TreeNode (string text);
new System.Web.UI.WebControls.TreeNode : string -> System.Web.UI.WebControls.TreeNode
Public Sub New (text As String)

Parametreler

text
String

Düğüm denetiminde TreeView görüntülenen metin.

Örnekler

Aşağıdaki kod örneği, denetime dinamik olarak bir düğüm eklemek için bu oluşturucunun TreeView nasıl kullanılacağını gösterir.


<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">

  void Page_Init(Object sender, EventArgs e)
  {
  
    if(!IsPostBack)
    {

      // Add the first tree to the TreeView control.
      CreateTree("Section 1");

      // Add the second tree to the TreeView control.
      CreateTree("Section 2");
    
    }

  }

  void CreateTree(String NodeText)
  {

    // Create the root node using the default constructor.
    TreeNode root = new TreeNode();
    root.Text = NodeText;

    // Use the ChildNodes property of the root TreeNode to add child nodes.
    // Create the node using the constructor that takes the text parameter.
    root.ChildNodes.Add(new TreeNode("Topic 1"));

    // Create the node using the constructor that takes the text and value parameters.
    root.ChildNodes.Add(new TreeNode("Topic 2", "Value 2"));

    // Create the node using the constructor that takes the text, value, 
    // and imageUrl parameters.
    root.ChildNodes.Add(new TreeNode("Topic 3", "Value 3", "Image1.jpg"));

    // Create the node using the constructor that takes the text, value, 
    // imageUrl, navigateUrl, and target parameters.
    root.ChildNodes.Add(new TreeNode("Topic 4", "Value 4", "Image1.jpg", "http://www.microsoft.com", "_blank"));

    // Add the root node to the Nodes collection of the TreeView control.
    DynamicTreeView.Nodes.Add(root);

  }

</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>TreeNode Constructor Example</title>
</head>
<body>
    <form id="form1" runat="server">
    
      <h3>TreeNode Constructor Example</h3>
      
      <asp:TreeView id="DynamicTreeView"
         EnableClientScript="false"
         ExpandDepth="2" 
         runat="server">
        
      </asp:TreeView>

    </form>
  </body>
</html>

<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">

  Sub Page_Init(ByVal sender As Object, ByVal e As EventArgs)

    If Not IsPostBack Then

      ' Add the first tree to the TreeView control.
      CreateTree("Section 1")

      ' Add the second tree to the TreeView control.
      CreateTree("Section 2")

    End If

  End Sub

  Sub CreateTree(ByVal NodeText As String)

    ' Create the root node using the default constructor.
    Dim root As TreeNode = New TreeNode
    root.Text = NodeText

    ' Use the ChildNodes property of the root TreeNode to add child nodes.
    ' Create the node using the constructor that takes the text parameter.
    root.ChildNodes.Add(New TreeNode("Topic 1"))

    ' Create the node using the constructor that takes the text and value parameters.
    root.ChildNodes.Add(New TreeNode("Topic 2", "Value 2"))

    ' Create the node using the constructor that takes the text, value, 
    ' and imageUrl parameters.
    root.ChildNodes.Add(New TreeNode("Topic 3", "Value 3", "Image1.jpg"))

    ' Create the node using the constructor that takes the text, value, 
    ' imageUrl, navigateUrl, and target parameters.
    root.ChildNodes.Add(New TreeNode("Topic 4", "Value 4", "Image1.jpg", "http://www.microsoft.com", "_blank"))

    ' Add the root node to the Nodes collection of the TreeView control.
    DynamicTreeView.Nodes.Add(root)

  End Sub

</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>TreeNode Constructor Example</title>
</head>
<body>
    <form id="form1" runat="server">
    
      <h3>TreeNode Constructor Example</h3>
      
      <asp:TreeView id="DynamicTreeView"
         EnableClientScript="false"
         ExpandDepth="2" 
         runat="server">
        
      </asp:TreeView>

    </form>
  </body>
</html>

Açıklamalar

parametresi tarafından belirtilen metni kullanarak sınıfın TreeNode yeni bir örneğini başlatmak için bu oluşturucuyu text kullanın.

Aşağıdaki tabloda, örneğinin ilk özellik değeri gösterilmektedir TreeNode.

Özellik İlk değer
Text parametresinin text değeri.

Ayrıca bkz.

Şunlara uygulanır

TreeNode(String, String)

Belirtilen metin ve değeri kullanarak sınıfının yeni bir örneğini TreeNode başlatır.

public:
 TreeNode(System::String ^ text, System::String ^ value);
public TreeNode (string text, string value);
new System.Web.UI.WebControls.TreeNode : string * string -> System.Web.UI.WebControls.TreeNode
Public Sub New (text As String, value As String)

Parametreler

text
String

Düğüm denetiminde TreeView görüntülenen metin.

value
String

Geri gönderme olaylarını işlemek için kullanılan veriler gibi düğümle ilişkili ek veriler.

Örnekler

Aşağıdaki kod örneği, denetime dinamik olarak bir düğüm eklemek için bu oluşturucunun TreeView nasıl kullanılacağını gösterir.


<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">

  void Page_Init(Object sender, EventArgs e)
  {
  
    if(!IsPostBack)
    {

      // Add the first tree to the TreeView control.
      CreateTree("Section 1");

      // Add the second tree to the TreeView control.
      CreateTree("Section 2");
    
    }

  }

  void CreateTree(String NodeText)
  {

    // Create the root node using the default constructor.
    TreeNode root = new TreeNode();
    root.Text = NodeText;

    // Use the ChildNodes property of the root TreeNode to add child nodes.
    // Create the node using the constructor that takes the text parameter.
    root.ChildNodes.Add(new TreeNode("Topic 1"));

    // Create the node using the constructor that takes the text and value parameters.
    root.ChildNodes.Add(new TreeNode("Topic 2", "Value 2"));

    // Create the node using the constructor that takes the text, value, 
    // and imageUrl parameters.
    root.ChildNodes.Add(new TreeNode("Topic 3", "Value 3", "Image1.jpg"));

    // Create the node using the constructor that takes the text, value, 
    // imageUrl, navigateUrl, and target parameters.
    root.ChildNodes.Add(new TreeNode("Topic 4", "Value 4", "Image1.jpg", "http://www.microsoft.com", "_blank"));

    // Add the root node to the Nodes collection of the TreeView control.
    DynamicTreeView.Nodes.Add(root);

  }

</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>TreeNode Constructor Example</title>
</head>
<body>
    <form id="form1" runat="server">
    
      <h3>TreeNode Constructor Example</h3>
      
      <asp:TreeView id="DynamicTreeView"
         EnableClientScript="false"
         ExpandDepth="2" 
         runat="server">
        
      </asp:TreeView>

    </form>
  </body>
</html>

<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">

  Sub Page_Init(ByVal sender As Object, ByVal e As EventArgs)

    If Not IsPostBack Then

      ' Add the first tree to the TreeView control.
      CreateTree("Section 1")

      ' Add the second tree to the TreeView control.
      CreateTree("Section 2")

    End If

  End Sub

  Sub CreateTree(ByVal NodeText As String)

    ' Create the root node using the default constructor.
    Dim root As TreeNode = New TreeNode
    root.Text = NodeText

    ' Use the ChildNodes property of the root TreeNode to add child nodes.
    ' Create the node using the constructor that takes the text parameter.
    root.ChildNodes.Add(New TreeNode("Topic 1"))

    ' Create the node using the constructor that takes the text and value parameters.
    root.ChildNodes.Add(New TreeNode("Topic 2", "Value 2"))

    ' Create the node using the constructor that takes the text, value, 
    ' and imageUrl parameters.
    root.ChildNodes.Add(New TreeNode("Topic 3", "Value 3", "Image1.jpg"))

    ' Create the node using the constructor that takes the text, value, 
    ' imageUrl, navigateUrl, and target parameters.
    root.ChildNodes.Add(New TreeNode("Topic 4", "Value 4", "Image1.jpg", "http://www.microsoft.com", "_blank"))

    ' Add the root node to the Nodes collection of the TreeView control.
    DynamicTreeView.Nodes.Add(root)

  End Sub

</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>TreeNode Constructor Example</title>
</head>
<body>
    <form id="form1" runat="server">
    
      <h3>TreeNode Constructor Example</h3>
      
      <asp:TreeView id="DynamicTreeView"
         EnableClientScript="false"
         ExpandDepth="2" 
         runat="server">
        
      </asp:TreeView>

    </form>
  </body>
</html>

Açıklamalar

Sırasıyla ve value parametreleri tarafından belirtilen metin ve değeri kullanarak sınıfın yeni bir örneğini TreeNode başlatmak için bu oluşturucuyu text kullanın.

Aşağıdaki tabloda, örneğinin ilk özellik değerleri gösterilmektedir TreeNode.

Özellik İlk değer
Text parametresinin text değeri.
Value parametresinin value değeri.

Ayrıca bkz.

Şunlara uygulanır

TreeNode(TreeView, Boolean)

Belirtilen sahibi kullanarak sınıfının yeni bir örneğini TreeNode başlatır.

protected public:
 TreeNode(System::Web::UI::WebControls::TreeView ^ owner, bool isRoot);
protected internal TreeNode (System.Web.UI.WebControls.TreeView owner, bool isRoot);
new System.Web.UI.WebControls.TreeNode : System.Web.UI.WebControls.TreeView * bool -> System.Web.UI.WebControls.TreeNode
Protected Friend Sub New (owner As TreeView, isRoot As Boolean)

Parametreler

owner
TreeView

TreeView yeni TreeNodeöğesini içerecektir.

isRoot
Boolean

trueTreeNode bir kök düğümse; değilse , false.

Ayrıca bkz.

Şunlara uygulanır

TreeNode(String, String, String)

Belirtilen metin, değer ve görüntü URL'sini TreeNode kullanarak sınıfın yeni bir örneğini başlatır.

public:
 TreeNode(System::String ^ text, System::String ^ value, System::String ^ imageUrl);
public TreeNode (string text, string value, string imageUrl);
new System.Web.UI.WebControls.TreeNode : string * string * string -> System.Web.UI.WebControls.TreeNode
Public Sub New (text As String, value As String, imageUrl As String)

Parametreler

text
String

Düğüm denetiminde TreeView görüntülenen metin.

value
String

Geri gönderme olaylarını işlemek için kullanılan veriler gibi düğümle ilişkili ek veriler.

imageUrl
String

Düğümün yanında görüntülenen görüntünün URL'si.

Örnekler

Aşağıdaki kod örneği, denetime dinamik olarak bir düğüm eklemek için bu oluşturucunun TreeView nasıl kullanılacağını gösterir.


<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">

  void Page_Init(Object sender, EventArgs e)
  {
  
    if(!IsPostBack)
    {

      // Add the first tree to the TreeView control.
      CreateTree("Section 1");

      // Add the second tree to the TreeView control.
      CreateTree("Section 2");
    
    }

  }

  void CreateTree(String NodeText)
  {

    // Create the root node using the default constructor.
    TreeNode root = new TreeNode();
    root.Text = NodeText;

    // Use the ChildNodes property of the root TreeNode to add child nodes.
    // Create the node using the constructor that takes the text parameter.
    root.ChildNodes.Add(new TreeNode("Topic 1"));

    // Create the node using the constructor that takes the text and value parameters.
    root.ChildNodes.Add(new TreeNode("Topic 2", "Value 2"));

    // Create the node using the constructor that takes the text, value, 
    // and imageUrl parameters.
    root.ChildNodes.Add(new TreeNode("Topic 3", "Value 3", "Image1.jpg"));

    // Create the node using the constructor that takes the text, value, 
    // imageUrl, navigateUrl, and target parameters.
    root.ChildNodes.Add(new TreeNode("Topic 4", "Value 4", "Image1.jpg", "http://www.microsoft.com", "_blank"));

    // Add the root node to the Nodes collection of the TreeView control.
    DynamicTreeView.Nodes.Add(root);

  }

</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>TreeNode Constructor Example</title>
</head>
<body>
    <form id="form1" runat="server">
    
      <h3>TreeNode Constructor Example</h3>
      
      <asp:TreeView id="DynamicTreeView"
         EnableClientScript="false"
         ExpandDepth="2" 
         runat="server">
        
      </asp:TreeView>

    </form>
  </body>
</html>

<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">

  Sub Page_Init(ByVal sender As Object, ByVal e As EventArgs)

    If Not IsPostBack Then

      ' Add the first tree to the TreeView control.
      CreateTree("Section 1")

      ' Add the second tree to the TreeView control.
      CreateTree("Section 2")

    End If

  End Sub

  Sub CreateTree(ByVal NodeText As String)

    ' Create the root node using the default constructor.
    Dim root As TreeNode = New TreeNode
    root.Text = NodeText

    ' Use the ChildNodes property of the root TreeNode to add child nodes.
    ' Create the node using the constructor that takes the text parameter.
    root.ChildNodes.Add(New TreeNode("Topic 1"))

    ' Create the node using the constructor that takes the text and value parameters.
    root.ChildNodes.Add(New TreeNode("Topic 2", "Value 2"))

    ' Create the node using the constructor that takes the text, value, 
    ' and imageUrl parameters.
    root.ChildNodes.Add(New TreeNode("Topic 3", "Value 3", "Image1.jpg"))

    ' Create the node using the constructor that takes the text, value, 
    ' imageUrl, navigateUrl, and target parameters.
    root.ChildNodes.Add(New TreeNode("Topic 4", "Value 4", "Image1.jpg", "http://www.microsoft.com", "_blank"))

    ' Add the root node to the Nodes collection of the TreeView control.
    DynamicTreeView.Nodes.Add(root)

  End Sub

</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>TreeNode Constructor Example</title>
</head>
<body>
    <form id="form1" runat="server">
    
      <h3>TreeNode Constructor Example</h3>
      
      <asp:TreeView id="DynamicTreeView"
         EnableClientScript="false"
         ExpandDepth="2" 
         runat="server">
        
      </asp:TreeView>

    </form>
  </body>
</html>

Açıklamalar

Sırasıyla , valueve imageUrl parametreleri tarafından belirtilen metin, değer ve görüntü URL'sini kullanarak sınıfın textyeni bir örneğini TreeNode başlatmak için bu oluşturucuyu kullanın.

Aşağıdaki tabloda, örneğinin ilk özellik değerleri gösterilmektedir TreeNode.

Özellik İlk değer
Text parametresinin text değeri.
Value parametresinin value değeri.
ImageUrl parametresinin imageUrl değeri.

Ayrıca bkz.

Şunlara uygulanır

TreeNode(String, String, String, String, String)

Belirtilen metni, değeri, görüntü URL'sini TreeNode , gezinti URL'sini ve hedefi kullanarak sınıfın yeni bir örneğini başlatır.

public:
 TreeNode(System::String ^ text, System::String ^ value, System::String ^ imageUrl, System::String ^ navigateUrl, System::String ^ target);
public TreeNode (string text, string value, string imageUrl, string navigateUrl, string target);
new System.Web.UI.WebControls.TreeNode : string * string * string * string * string -> System.Web.UI.WebControls.TreeNode
Public Sub New (text As String, value As String, imageUrl As String, navigateUrl As String, target As String)

Parametreler

text
String

Düğüm denetiminde TreeView görüntülenen metin.

value
String

Geri gönderme olaylarını işlemek için kullanılan veriler gibi düğümle ilişkili ek veriler.

imageUrl
String

Düğümün yanında görüntülenen görüntünün URL'si.

navigateUrl
String

Düğüme tıklandığında bağlanılacak URL.

target
String

Düğüme tıklandığında bağlanılan Web sayfası içeriğinin görüntüleneceği hedef pencere veya çerçeve.

Örnekler

Aşağıdaki kod örneği, denetime dinamik olarak bir düğüm eklemek için bu oluşturucunun TreeView nasıl kullanılacağını gösterir.


<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">

  void Page_Init(Object sender, EventArgs e)
  {
  
    if(!IsPostBack)
    {

      // Add the first tree to the TreeView control.
      CreateTree("Section 1");

      // Add the second tree to the TreeView control.
      CreateTree("Section 2");
    
    }

  }

  void CreateTree(String NodeText)
  {

    // Create the root node using the default constructor.
    TreeNode root = new TreeNode();
    root.Text = NodeText;

    // Use the ChildNodes property of the root TreeNode to add child nodes.
    // Create the node using the constructor that takes the text parameter.
    root.ChildNodes.Add(new TreeNode("Topic 1"));

    // Create the node using the constructor that takes the text and value parameters.
    root.ChildNodes.Add(new TreeNode("Topic 2", "Value 2"));

    // Create the node using the constructor that takes the text, value, 
    // and imageUrl parameters.
    root.ChildNodes.Add(new TreeNode("Topic 3", "Value 3", "Image1.jpg"));

    // Create the node using the constructor that takes the text, value, 
    // imageUrl, navigateUrl, and target parameters.
    root.ChildNodes.Add(new TreeNode("Topic 4", "Value 4", "Image1.jpg", "http://www.microsoft.com", "_blank"));

    // Add the root node to the Nodes collection of the TreeView control.
    DynamicTreeView.Nodes.Add(root);

  }

</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>TreeNode Constructor Example</title>
</head>
<body>
    <form id="form1" runat="server">
    
      <h3>TreeNode Constructor Example</h3>
      
      <asp:TreeView id="DynamicTreeView"
         EnableClientScript="false"
         ExpandDepth="2" 
         runat="server">
        
      </asp:TreeView>

    </form>
  </body>
</html>

<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">

  Sub Page_Init(ByVal sender As Object, ByVal e As EventArgs)

    If Not IsPostBack Then

      ' Add the first tree to the TreeView control.
      CreateTree("Section 1")

      ' Add the second tree to the TreeView control.
      CreateTree("Section 2")

    End If

  End Sub

  Sub CreateTree(ByVal NodeText As String)

    ' Create the root node using the default constructor.
    Dim root As TreeNode = New TreeNode
    root.Text = NodeText

    ' Use the ChildNodes property of the root TreeNode to add child nodes.
    ' Create the node using the constructor that takes the text parameter.
    root.ChildNodes.Add(New TreeNode("Topic 1"))

    ' Create the node using the constructor that takes the text and value parameters.
    root.ChildNodes.Add(New TreeNode("Topic 2", "Value 2"))

    ' Create the node using the constructor that takes the text, value, 
    ' and imageUrl parameters.
    root.ChildNodes.Add(New TreeNode("Topic 3", "Value 3", "Image1.jpg"))

    ' Create the node using the constructor that takes the text, value, 
    ' imageUrl, navigateUrl, and target parameters.
    root.ChildNodes.Add(New TreeNode("Topic 4", "Value 4", "Image1.jpg", "http://www.microsoft.com", "_blank"))

    ' Add the root node to the Nodes collection of the TreeView control.
    DynamicTreeView.Nodes.Add(root)

  End Sub

</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>TreeNode Constructor Example</title>
</head>
<body>
    <form id="form1" runat="server">
    
      <h3>TreeNode Constructor Example</h3>
      
      <asp:TreeView id="DynamicTreeView"
         EnableClientScript="false"
         ExpandDepth="2" 
         runat="server">
        
      </asp:TreeView>

    </form>
  </body>
</html>

Açıklamalar

Metin, değer, görüntü ve gezinti URL'lerini kullanarak sınıfın TreeNode yeni bir örneğini başlatmak ve sırasıyla , value, , imageUrlnavigateUrlve target parametreleri tarafından textbelirtilen hedefi görüntülemek için bu oluşturucuyu kullanın.

Aşağıdaki tabloda, örneğinin ilk özellik değerleri gösterilmektedir TreeNode.

Özellik İlk değer
Text parametresinin text değeri.
Value parametresinin value değeri.
ImageUrl parametresinin imageUrl değeri.
NavigateUrl parametresinin navigateUrl değeri.
Target parametresinin target değeri.

Ayrıca bkz.

Şunlara uygulanır