TreeNode Costruttori
Definizione
Importante
Alcune informazioni sono relative alla release non definitiva del prodotto, che potrebbe subire modifiche significative prima della release definitiva. Microsoft non riconosce alcuna garanzia, espressa o implicita, in merito alle informazioni qui fornite.
Inizializza una nuova istanza della classe TreeNode.
Overload
TreeNode() |
Inizializza una nuova istanza della classe TreeNode senza testo o un valore. |
TreeNode(String) |
Consente l'inizializzazione di una nuova istanza della classe TreeNode con il testo specificato. |
TreeNode(String, String) |
Inizializza una nuova istanza della classe TreeNode con il testo e il valore specificati. |
TreeNode(TreeView, Boolean) |
Inizializza una nuova istanza della classe TreeNode utilizzando il proprietario specificato. |
TreeNode(String, String, String) |
Inizializza una nuova istanza della classe TreeNode con il testo, il valore e l'URL dell'immagine specificati. |
TreeNode(String, String, String, String, String) |
Inizializza una nuova istanza della classe TreeNode utilizzando il testo, il valore, l'URL dell'immagine, l'URL di navigazione e la destinazione specificati. |
TreeNode()
Inizializza una nuova istanza della classe TreeNode senza testo o un valore.
public:
TreeNode();
public TreeNode ();
Public Sub New ()
Esempio
Nell'esempio di codice seguente viene illustrato come usare questo costruttore per aggiungere dinamicamente un nodo al TreeView controllo.
<%@ 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>
Commenti
Utilizzare questo costruttore per inizializzare una nuova istanza della TreeNode classe utilizzando i valori predefiniti.
Nota
Quando questo costruttore viene utilizzato, tutte le proprietà dell'oggetto TreeNode vengono impostate sui valori predefiniti. Assicurarsi di impostare le proprietà, se necessario, dopo aver creato l'oggetto .
Vedi anche
Si applica a
TreeNode(String)
Consente l'inizializzazione di una nuova istanza della classe TreeNode con il testo specificato.
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)
Parametri
Esempio
Nell'esempio di codice seguente viene illustrato come usare questo costruttore per aggiungere dinamicamente un nodo al TreeView controllo.
<%@ 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>
Commenti
Utilizzare questo costruttore per inizializzare una nuova istanza della TreeNode classe utilizzando il testo specificato dal text
parametro .
Nella tabella seguente viene illustrato il valore iniziale della proprietà per un'istanza di TreeNode.
Proprietà | Valore iniziale |
---|---|
Text | Valore del parametro text . |
Vedi anche
Si applica a
TreeNode(String, String)
Inizializza una nuova istanza della classe TreeNode con il testo e il valore specificati.
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)
Parametri
- value
- String
Dati aggiuntivi associati al nodo, ad esempio i dati utilizzati per la gestione degli eventi di postback.
Esempio
Nell'esempio di codice seguente viene illustrato come usare questo costruttore per aggiungere dinamicamente un nodo al TreeView controllo.
<%@ 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>
Commenti
Utilizzare questo costruttore per inizializzare una nuova istanza della TreeNode classe usando rispettivamente il testo e il valore specificati dai text
parametri e value
.
Nella tabella seguente vengono illustrati i valori iniziali delle proprietà per un'istanza di TreeNode.
Proprietà | Valore iniziale |
---|---|
Text | Valore del parametro text . |
Value | Valore del parametro value . |
Vedi anche
Si applica a
TreeNode(TreeView, Boolean)
Inizializza una nuova istanza della classe TreeNode utilizzando il proprietario specificato.
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)
Parametri
Vedi anche
Si applica a
TreeNode(String, String, String)
Inizializza una nuova istanza della classe TreeNode con il testo, il valore e l'URL dell'immagine specificati.
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)
Parametri
- value
- String
Dati aggiuntivi associati al nodo, ad esempio i dati utilizzati per la gestione degli eventi di postback.
- imageUrl
- String
URL di un'immagine visualizzata accanto al nodo.
Esempio
Nell'esempio di codice seguente viene illustrato come usare questo costruttore per aggiungere dinamicamente un nodo al TreeView controllo.
<%@ 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>
Commenti
Usare questo costruttore per inizializzare una nuova istanza della TreeNode classe usando rispettivamente il testo, il valore e l'URL dell'immagine specificati dai text
parametri , value
e imageUrl
.
Nella tabella seguente vengono illustrati i valori iniziali delle proprietà per un'istanza di TreeNode.
Proprietà | Valore iniziale |
---|---|
Text | Valore del parametro text . |
Value | Valore del parametro value . |
ImageUrl | Valore del parametro imageUrl . |
Vedi anche
Si applica a
TreeNode(String, String, String, String, String)
Inizializza una nuova istanza della classe TreeNode utilizzando il testo, il valore, l'URL dell'immagine, l'URL di navigazione e la destinazione specificati.
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)
Parametri
- value
- String
Dati aggiuntivi associati al nodo, ad esempio i dati utilizzati per la gestione degli eventi di postback.
- imageUrl
- String
URL di un'immagine visualizzata accanto al nodo.
- navigateUrl
- String
L'URL a cui eseguire il collegamento quando si fa clic sul nodo.
- target
- String
La finestra o il frame di destinazione in cui visualizzare il contenuto della pagina Web cui collegato quando viene fatto clic sul nodo.
Esempio
Nell'esempio di codice seguente viene illustrato come usare questo costruttore per aggiungere dinamicamente un nodo al TreeView controllo.
<%@ 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>
Commenti
Usare questo costruttore per inizializzare una nuova istanza della TreeNode classe usando rispettivamente il testo, il valore, l'immagine e gli URL di navigazione e la destinazione di visualizzazione specificati dai text
parametri , value
, imageUrl
navigateUrl
, e target
.
Nella tabella seguente vengono illustrati i valori iniziali delle proprietà per un'istanza di TreeNode.
Proprietà | Valore iniziale |
---|---|
Text | Valore del parametro text . |
Value | Valore del parametro value . |
ImageUrl | Valore del parametro imageUrl . |
NavigateUrl | Valore del parametro navigateUrl . |
Target | Valore del parametro target . |