Bagikan melalui


TreeView.NoExpandImageUrl Properti

Definisi

Mendapatkan atau mengatur URL ke gambar kustom untuk indikator simpul yang tidak dapat diperluas.

public:
 property System::String ^ NoExpandImageUrl { System::String ^ get(); void set(System::String ^ value); };
public string NoExpandImageUrl { get; set; }
member this.NoExpandImageUrl : string with get, set
Public Property NoExpandImageUrl As String

Nilai Properti

URL ke gambar kustom yang ditampilkan untuk simpul yang tidak dapat diperluas. Defaultnya adalah string kosong (""), yang menampilkan gambar kosong default.

Contoh

Contoh kode berikut menunjukkan cara menggunakan NoExpandImageUrl properti untuk menentukan gambar kustom untuk indikator simpul yang tidak dapat diperluas. Agar contoh kode ditampilkan dan gambar muncul dalam kontrol, Anda harus menyediakan gambar Anda sendiri dan ImageSet properti harus diatur ke 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>

Keterangan

NoExpandImageUrl Gunakan properti untuk menentukan gambar kustom untuk indikator simpul yang tidak dapat diperluas. Gambar indikator simpul yang tidak dapat diperluas (atau spacer) ditampilkan di samping simpul daun (sebagai pengganti indikator node yang dapat diperluas dan dapat diciutkan) untuk menyelaraskan simpul daun dengan node induk atau akar.

ShowExpandCollapse Ketika properti diatur ke true, TreeView kontrol menampilkan tanda plus (+) atau tanda minus (-) atau gambar tempat penampung di samping simpul untuk menunjukkan apakah simpul dapat diperluas, diciutkan, atau tidak dapat diperluas, masing-masing. Anda dapat menentukan gambar kustom dengan terlebih dahulu mengatur ImageSet properti ke TreeViewImageSet.Custom, lalu mengatur NoExpandImageUrlproperti , ExpandImageUrl, dan CollapseImageUrl ke URL gambar kustom. Jika tidak ada gambar yang ditentukan, gambar default akan digunakan. Untuk menyembunyikan indikator simpul ekspansi, atur ShowExpandCollapse properti ke false.

Nota

Untuk memastikan bahwa simpul selaras dengan benar dalam TreeView kontrol saat menggunakan gambar kustom, pastikan bahwa semua gambar yang ditentukan oleh NoExpandImageUrlproperti , , ExpandImageUrldan CollapseImageUrl memiliki dimensi yang sama.

Nilai properti ini disimpan dalam status tampilan.

Berlaku untuk

Lihat juga