TreeView controle de servidor Web Declarative sintaxe
Exibe dados hierárquicos, sistema autônomo um tabela analítico em uma estrutura de árvore.
<asp:TreeView
AccessKey="string"
AutoGenerateDataBindings="True|False"
BackColor="color name|#dddddd"
BorderColor="color name|#dddddd"
BorderStyle="NotSet|None|Dotted|Dashed|Solid|Double|Groove|Ridge|
Inset|Outset"
BorderWidth="size"
CollapseImageToolTip="string"
CollapseImageUrl="uri"
CssClass="string"
DataSource="string"
DataSourceID="string"
EnableClientScript="True|False"
Enabled="True|False"
EnableTheming="True|False"
EnableViewState="True|False"
ExpandDepth="string|FullyExpand|0|1|2|3|4|5|6|7|8|9|10|11|12|13|
14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30"
ExpandImageToolTip="string"
ExpandImageUrl="uri"
Font-Bold="True|False"
Font-Italic="True|False"
Font-Names="string"
Font-Overline="True|False"
Font-Size="string|Smaller|Larger|XX-Small|X-Small|Small|Medium|
Large|X-Large|XX-Large"
Font-Strikeout="True|False"
Font-Underline="True|False"
ForeColor="color name|#dddddd"
Height="size"
ID="string"
ImageSet="Custom|XPFileExplorer|Msdn|WindowsHelp|Simple|Simple2|
BulletedList|BulletedList2|BulletedList3|BulletedList4|
Arrows|News|Contacts|Inbox|Events|Faq"
LineImagesFolder="string"
MaxDataBindDepth="integer"
NodeIndent="integer"
NodeWrap="True|False"
NoExpandImageUrl="uri"
OnDataBinding="DataBinding event handler"
OnDataBound="DataBound event handler"
OnDisposed="Disposed event handler"
OnInit="Init event handler"
OnLoad="Load event handler"
OnPreRender="PreRender event handler"
OnSelectedNodeChanged="SelectedNodeChanged event handler"
OnTreeNodeCheckChanged="TreeNodeCheckChanged event handler"
OnTreeNodeCollapsed="TreeNodeCollapsed event handler"
OnTreeNodeDataBound="TreeNodeDataBound event handler"
OnTreeNodeExpanded="TreeNodeExpanded event handler"
OnTreeNodePopulate="TreeNodePopulate event handler"
OnUnload="Unload event handler"
PathSeparator="string"
PopulateNodesFromClient="True|False"
runat="server"
ShowCheckBoxes="None|Root|Parent|Leaf|All"
ShowExpandCollapse="True|False"
ShowLines="True|False"
SkinID="string"
SkipLinkText="string"
Style="string"
TabIndex="integer"
Target="string"
ToolTip="string"
Visible="True|False"
Width="size"
>
<DataBindings>
<asp:TreeNodeBinding
DataMember="string"
Depth="integer"
FormatString="string"
ImageToolTip="string"
ImageToolTipField="string"
ImageUrl="uri"
ImageUrlField="string"
href="uri"
hrefField="string"
PopulateOnDemand="True|False"
SelectAction="Select|Expand|SelectExpand|None"
ShowCheckBox="string"
Target="string"
TargetField="string"
Text="string"
TextField="string"
ToolTip="string"
ToolTipField="string"
Value="string"
ValueField="string"
/>
</DataBindings>
<HoverNodeStyle />
<LeafNodeStyle
BackColor="color name|#dddddd"
BorderColor="color name|#dddddd"
BorderStyle="NotSet|None|Dotted|Dashed|Solid|Double|
Groove|Ridge|Inset|Outset"
BorderWidth="size"
ChildNodesPadding="size"
CssClass="string"
Font-Bold="True|False"
Font-Italic="True|False"
Font-Names="string"
Font-Overline="True|False"
Font-Size="string|Smaller|Larger|XX-Small|X-Small|Small|
Medium|Large|X-Large|XX-Large"
Font-Strikeout="True|False"
Font-Underline="True|False"
ForeColor="color name|#dddddd"
Height="size"
HorizontalPadding="size"
ImageUrl="uri"
NodeSpacing="size"
OnDisposed="Disposed event handler"
VerticalPadding="size"
Width="size"
/>
<LevelStyles>
<asp:TreeNodeStyle
BackColor="color name|#dddddd"
BorderColor="color name|#dddddd"
BorderStyle="NotSet|None|Dotted|Dashed|Solid|
Double|Groove|Ridge|Inset|Outset"
BorderWidth="size"
ChildNodesPadding="size"
CssClass="string"
Font-Bold="True|False"
Font-Italic="True|False"
Font-Names="string"
Font-Overline="True|False"
Font-Size="string|Smaller|Larger|XX-Small|
X-Small|Small|Medium|Large|X-Large|XX-Large"
Font-Strikeout="True|False"
Font-Underline="True|False"
ForeColor="color name|#dddddd"
Height="size"
HorizontalPadding="size"
ImageUrl="uri"
NodeSpacing="size"
OnDisposed="Disposed event handler"
VerticalPadding="size"
Width="size"
/>
</LevelStyles>
<Nodes>
<asp:TreeNode
Checked="True|False"
Expanded="string"
ImageToolTip="string"
ImageUrl="uri"
href="uri"
PopulateOnDemand="True|False"
SelectAction="Select|Expand|SelectExpand|None"
Selected="True|False"
ShowCheckBox="string"
Target="string"
Text="string"
ToolTip="string"
Value="string"
>
</asp:TreeNode>
</Nodes>
<NodeStyle
BackColor="color name|#dddddd"
BorderColor="color name|#dddddd"
BorderStyle="NotSet|None|Dotted|Dashed|Solid|Double|
Groove|Ridge|Inset|Outset"
BorderWidth="size"
ChildNodesPadding="size"
CssClass="string"
Font-Bold="True|False"
Font-Italic="True|False"
Font-Names="string"
Font-Overline="True|False"
Font-Size="string|Smaller|Larger|XX-Small|X-Small|Small|
Medium|Large|X-Large|XX-Large"
Font-Strikeout="True|False"
Font-Underline="True|False"
ForeColor="color name|#dddddd"
Height="size"
HorizontalPadding="size"
ImageUrl="uri"
NodeSpacing="size"
OnDisposed="Disposed event handler"
VerticalPadding="size"
Width="size"
/>
<ParentNodeStyle
BackColor="color name|#dddddd"
BorderColor="color name|#dddddd"
BorderStyle="NotSet|None|Dotted|Dashed|Solid|Double|
Groove|Ridge|Inset|Outset"
BorderWidth="size"
ChildNodesPadding="size"
CssClass="string"
Font-Bold="True|False"
Font-Italic="True|False"
Font-Names="string"
Font-Overline="True|False"
Font-Size="string|Smaller|Larger|XX-Small|X-Small|Small|
Medium|Large|X-Large|XX-Large"
Font-Strikeout="True|False"
Font-Underline="True|False"
ForeColor="color name|#dddddd"
Height="size"
HorizontalPadding="size"
ImageUrl="uri"
NodeSpacing="size"
OnDisposed="Disposed event handler"
VerticalPadding="size"
Width="size"
/>
<RootNodeStyle
BackColor="color name|#dddddd"
BorderColor="color name|#dddddd"
BorderStyle="NotSet|None|Dotted|Dashed|Solid|Double|
Groove|Ridge|Inset|Outset"
BorderWidth="size"
ChildNodesPadding="size"
CssClass="string"
Font-Bold="True|False"
Font-Italic="True|False"
Font-Names="string"
Font-Overline="True|False"
Font-Size="string|Smaller|Larger|XX-Small|X-Small|Small|
Medium|Large|X-Large|XX-Large"
Font-Strikeout="True|False"
Font-Underline="True|False"
ForeColor="color name|#dddddd"
Height="size"
HorizontalPadding="size"
ImageUrl="uri"
NodeSpacing="size"
OnDisposed="Disposed event handler"
VerticalPadding="size"
Width="size"
/>
<SelectedNodeStyle
BackColor="color name|#dddddd"
BorderColor="color name|#dddddd"
BorderStyle="NotSet|None|Dotted|Dashed|Solid|Double|
Groove|Ridge|Inset|Outset"
BorderWidth="size"
ChildNodesPadding="size"
CssClass="string"
Font-Bold="True|False"
Font-Italic="True|False"
Font-Names="string"
Font-Overline="True|False"
Font-Size="string|Smaller|Larger|XX-Small|X-Small|Small|
Medium|Large|X-Large|XX-Large"
Font-Strikeout="True|False"
Font-Underline="True|False"
ForeColor="color name|#dddddd"
Height="size"
HorizontalPadding="size"
ImageUrl="uri"
NodeSpacing="size"
OnDisposed="Disposed event handler"
VerticalPadding="size"
Width="size"
/>
</asp:TreeView>
Comentários
The TreeView controle é usado para exibir dados hierárquicos, tais sistema autônomo um índice de Sumário ou um diretório de arquivo em uma estrutura de árvore e suporta sistema autônomo seguintes recursos:
Suporte permite que os nós do controle deve ser limite ao XML, tabular, vinculação de dados ou dados relacionais.
Site navigation support through integration with the SiteMapDataSource control.
Texto do nó que pode ser exibido sistema autônomo texto sem formatação ou hiperlinks.
Acesso programático para o TreeView modelo de objeto para criar árvores, preencha nós, conjunto propriedades e assim por diante, dinamicamente.
população de nós do lado do cliente (em navegadores suportados).
A capacidade de exibir uma caixa de seleção ao lado de cada nó.
A capacidade de personalizar a aparência por meio de temas, imagens definidas pelo usuário e estilos.
Para obter mais informação sobre o controle TreeView, veja Visão geral do Controle do Servidor Web TreeView.
Exemplo
O exemplo de código a seguir demonstra como BIND o TreeView controle a uma fonte de dados XML.
<asp:TreeView id="BookTreeView" dataSourceID="BookXmlDataSource" runat="server">
<DataBindings>
<asp:TreeNodeBinding DataMember="Book" TextField="Title"/>
<asp:TreeNodeBinding DataMember="Chapter" TextField="Heading"/>
<asp:TreeNodeBinding DataMember="Section" TextField="Heading"/>
</DataBindings>
</asp:TreeView>
<asp:XmlDataSource id="BookXmlDataSource" runat="server">
<Data>
<Book Title="Book Title">
<Chapter Heading="Chapter 1">
<Section Heading="Section 1">
</Section>
<Section Heading="Section 2">
</Section>
</Chapter>
<Chapter Heading="Chapter 2">
<Section Heading="Section 1">
</Section>
</Chapter>
</Book>
</Data>
</asp:XmlDataSource>
<asp:TreeView id="BookTreeView" dataSourceID="BookXmlDataSource" runat="server">
<DataBindings>
<asp:TreeNodeBinding DataMember="Book" TextField="Title"/>
<asp:TreeNodeBinding DataMember="Chapter" TextField="Heading"/>
<asp:TreeNodeBinding DataMember="Section" TextField="Heading"/>
</DataBindings>
</asp:TreeView>
<asp:XmlDataSource id="BookXmlDataSource" runat="server">
<Data>
<Book Title="Book Title">
<Chapter Heading="Chapter 1">
<Section Heading="Section 1">
</Section>
<Section Heading="Section 2">
</Section>
</Chapter>
<Chapter Heading="Chapter 2">
<Section Heading="Section 1">
</Section>
</Chapter>
</Book>
</Data>
</asp:XmlDataSource>