TreeView.CollapseImageUrl Propriedade
Definição
Obtém ou define a URL para uma imagem personalizada para o indicador de nó recolhível.Gets or sets the URL to a custom image for the collapsible node indicator.
public:
property System::String ^ CollapseImageUrl { System::String ^ get(); void set(System::String ^ value); };
public string CollapseImageUrl { get; set; }
member this.CollapseImageUrl : string with get, set
Public Property CollapseImageUrl As String
Valor da propriedade
A URL para uma imagem personalizada a ser exibida para nós recolhíveis.The URL to a custom image to display for collapsible nodes. O padrão é uma cadeia de caracteres vazia (""), que exibe a imagem do sinal de subtração (-) padrão.The default is an empty string (""), which displays the default minus sign (-) image.
Exemplos
O exemplo de código a seguir demonstra como usar a CollapseImageUrl propriedade para especificar uma imagem personalizada para o indicador de nó recolhível.The following code example demonstrates how to use the CollapseImageUrl property to specify a custom image for the collapsible node indicator. Para que o exemplo de código seja exibido e a imagem apareça no controle, você deve fornecer sua própria imagem e a ImageSet propriedade deve ser definida como TreeNodeImageSet.Custom .For the code example to display and the image to appear in the control, you must provide your own image and the ImageSet property must be set to TreeNodeImageSet.Custom.
<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>TreeView Custom Images Example</title>
</head>
<body>
<form id="form1" runat="server">
<h3>TreeView Custom Images Example</h3>
<!-- Set the custom images of this TreeView control -->
<!-- declaratively. -->
<asp:TreeView id="CustomTreeView"
NoExpandImageUrl="Space.jpg"
CollapseImageUrl="Minus.jpg"
CollapseImageToolTip="Collapse Node"
ExpandImageUrl="Plus.jpg"
ExpandImageToolTip="Expand Node"
RootNodeStyle-ImageUrl="Root.jpg"
ParentNodeStyle-ImageUrl="Parent.jpg"
LeafNodeStyle-ImageUrl="Leaf.jpg"
ImageSet="Custom"
runat="server">
<Nodes>
<asp:TreeNode Value="Home"
NavigateUrl="Home.aspx"
Text="Home"
Target="_blank"
Expanded="True">
<asp:TreeNode Value="Page 1"
NavigateUrl="Page1.aspx"
Text="Page 1"
Target="_blank">
<asp:TreeNode Value="Section 1"
ImageUrl="custom.jpg"
NavigateUrl="Section1.aspx"
Text="Section 1"
Target="_blank">
</asp:TreeNode>
</asp:TreeNode>
<asp:TreeNode Value="Page 2"
Selected="True"
NavigateUrl="Page2.aspx"
Text="Page 2"
Target="_blank">
</asp:TreeNode>
</asp:TreeNode>
</Nodes>
</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">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>TreeView Custom Images Example</title>
</head>
<body>
<form id="form1" runat="server">
<h3>TreeView Custom Images Example</h3>
<!-- Set the custom images of this TreeView control -->
<!-- declaratively. -->
<asp:TreeView id="CustomTreeView"
NoExpandImageUrl="Space.jpg"
CollapseImageUrl="Minus.jpg"
CollapseImageToolTip="Collapse Node"
ExpandImageUrl="Plus.jpg"
ExpandImageToolTip="Expand Node"
RootNodeStyle-ImageUrl="Root.jpg"
ParentNodeStyle-ImageUrl="Parent.jpg"
LeafNodeStyle-ImageUrl="Leaf.jpg"
ImageSet="Custom"
runat="server">
<Nodes>
<asp:TreeNode Value="Home"
NavigateUrl="Home.aspx"
Text="Home"
Target="_blank"
Expanded="True">
<asp:TreeNode Value="Page 1"
NavigateUrl="Page1.aspx"
Text="Page 1"
Target="_blank">
<asp:TreeNode Value="Section 1"
ImageUrl="custom.jpg"
NavigateUrl="Section1.aspx"
Text="Section 1"
Target="_blank">
</asp:TreeNode>
</asp:TreeNode>
<asp:TreeNode Value="Page 2"
Selected="True"
NavigateUrl="Page2.aspx"
Text="Page 2"
Target="_blank">
</asp:TreeNode>
</asp:TreeNode>
</Nodes>
</asp:TreeView>
</form>
</body>
</html>
Comentários
Use a CollapseImageUrl propriedade para especificar uma imagem personalizada para o indicador de nó recolhível.Use the CollapseImageUrl property to specify a custom image for the collapsible node indicator. Essa imagem é exibida ao lado de um nó recolhível e geralmente é um sinal de menos (-).This image is displayed next to a collapsible node and is usually a minus sign (-).
Quando a ShowExpandCollapse propriedade é definida como true , o TreeView controle exibe um sinal de adição (+) ou um sinal de subtração (-) ou uma imagem de espaço reservado ao lado de um nó para indicar se o nó é expansível, recolhível ou não expansível, respectivamente.When the ShowExpandCollapse property is set to true, the TreeView control displays a plus sign (+) or a minus sign(-) or a placeholder image next to a node to indicate whether the node is expandable, collapsible, or non-expandable, respectively. Você pode especificar imagens personalizadas primeiro definindo a ImageSet propriedade como TreeViewImageSet.Custom e, em seguida, definindo NoExpandImageUrl as ExpandImageUrl Propriedades, e CollapseImageUrl para as URLs para as imagens personalizadas.You can specify custom images by first setting the ImageSet property to TreeViewImageSet.Custom, and then setting the NoExpandImageUrl, ExpandImageUrl, and CollapseImageUrl properties to the URLs for the custom images. Se nenhuma imagem for especificada, as imagens padrão serão usadas.If no images are specified, the default images are used. Para ocultar os indicadores de nó de expansão, defina a ShowExpandCollapse propriedade como false .To hide the expansion node indicators, set the ShowExpandCollapse property to false.
Observação
Para garantir que os nós se alinhem corretamente no TreeView controle ao usar imagens personalizadas, verifique se todas as imagens especificadas pelas NoExpandImageUrl ExpandImageUrl Propriedades, e CollapseImageUrl têm as mesmas dimensões.To ensure that nodes align correctly in the TreeView control when using custom images, make sure that all the images that are specified by the NoExpandImageUrl, ExpandImageUrl, and CollapseImageUrl properties have the same dimensions.
Ao usar uma imagem personalizada para o indicador de nó recolhível, você também deve considerar definir a CollapseImageToolTip propriedade para especificar uma dica de ferramenta para a imagem.When using a custom image for the collapsible node indicator, you should also consider setting the CollapseImageToolTip property to specify a ToolTip for the image.
O valor dessa propriedade é armazenado em estado de exibição.The value of this property is stored in view state.