다음을 통해 공유


TreeNodeStyle.CopyFrom(Style) 메서드

정의

지정된 Style 개체의 스타일 속성을 현재 TreeNodeStyle 개체로 복사합니다.

public:
 override void CopyFrom(System::Web::UI::WebControls::Style ^ s);
public override void CopyFrom (System.Web.UI.WebControls.Style s);
override this.CopyFrom : System.Web.UI.WebControls.Style -> unit
Public Overrides Sub CopyFrom (s As Style)

매개 변수

s
Style

복사할 Style입니다.

예제

다음 코드 예제를 사용 하는 방법에 설명 합니다 CopyFrom 지정 된 스타일 속성을 복사 하는 방법 Style 개체를 TreeNodeStyle 이 메서드를 호출 하는 개체입니다. 모든 스타일 속성 바뀝니다 알 수 있습니다.


<%@ 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 Button_Click(Object sender, EventArgs e)
  {

    // Copy the leaf node styles from the TreeNodeOne TreeView into the 
    // TreeViewResults TreeView.
    TreeViewResults.LeafNodeStyle.CopyFrom(TreeViewOne.LeafNodeStyle);

  }

</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>TreeNodeStyle CopyFrom Example</title>
</head>
<body>  
    <form id="form1" runat="server">
    
      <h3>TreeNodeStyle CopyFrom Example</h3>
      
      <table cellspacing="30">
        
        <tr>
        
          <th>
          
            TreeView One
          
          </th>
          
          <th>
          
            TreeView Result
          
          </th>
        
        </tr>
        
        <tr valign="top">
        
          <td>
          
            <!-- Set the styles for the leaf nodes declaratively. -->
            <asp:TreeView id="TreeViewOne"
              ExpandDepth="4" 
              LeafNodeStyle-BackColor="Yellow"
              LeafNodeStyle-Font-Bold="true"  
              LeafNodeStyle-ForeColor="Black"  
              runat="server">
         
              <Nodes>
        
                <asp:TreeNode Text="Table of Contents"
                  SelectAction="None">
             
                  <asp:TreeNode Text="Chapter One">
            
                    <asp:TreeNode Text="Section 1.0">
              
                      <asp:TreeNode Text="Topic 1.0.1"/>
                      <asp:TreeNode Text="Topic 1.0.2"/>
                      <asp:TreeNode Text="Topic 1.0.3"/>
              
                    </asp:TreeNode>
              
                  </asp:TreeNode>
            
                </asp:TreeNode>
        
              </Nodes>
        
            </asp:TreeView>
          
          </td>
          
          <td>
          
            <!-- Set the styles for the leaf nodes declaratively. -->
            <asp:TreeView id="TreeViewResults"
              ExpandDepth="4"   
              runat="server">
         
              <Nodes>
        
                <asp:TreeNode Text="Table of Contents"
                  SelectAction="None">
             
                  <asp:TreeNode Text="Chapter One">
            
                    <asp:TreeNode Text="Section 1.0">
              
                      <asp:TreeNode Text="Topic 1.0.1"/>
                      <asp:TreeNode Text="Topic 1.0.2"/>
                      <asp:TreeNode Text="Topic 1.0.3"/>
              
                    </asp:TreeNode>
              
                  </asp:TreeNode>
            
                </asp:TreeNode>
        
              </Nodes>
        
            </asp:TreeView>
          
          </td>
        
        </tr>
        
        <tr>
        
          <td>
          
            <asp:Button ID="CopyNodeStyleButton" 
              Text="Copy LeafNodeStyle"
              OnClick="Button_Click" 
              runat="server"/>
          
          </td>
          
          <td>
          
             
          
          </td>
        
        </tr>
      
      </table>
       
    </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 Button_Click(ByVal sender As Object, ByVal e As EventArgs)

    ' Copy the leaf node styles from the TreeNodeOne TreeView into the 
    ' TreeViewResults TreeView.
    TreeViewResults.LeafNodeStyle.CopyFrom(TreeViewOne.LeafNodeStyle)

  End Sub

</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>TreeNodeStyle CopyFrom Example</title>
</head>
<body>  
    <form id="form1" runat="server">
    
      <h3>TreeNodeStyle CopyFrom Example</h3>
      
      <table cellspacing="30">
        
        <tr>
        
          <th>
          
            TreeView One
          
          </th>
          
          <th>
          
            TreeView Result
          
          </th>
        
        </tr>
        
        <tr valign="top">
        
          <td>
          
            <!-- Set the styles for the leaf nodes declaratively. -->
            <asp:TreeView id="TreeViewOne"
              ExpandDepth="4"
              LeafNodeStyle-BackColor="Yellow"
              LeafNodeStyle-Font-Bold="true"  
              LeafNodeStyle-ForeColor="Black"   
              runat="server">
         
              <Nodes>
        
                <asp:TreeNode Text="Table of Contents"
                  SelectAction="None">
             
                  <asp:TreeNode Text="Chapter One">
            
                    <asp:TreeNode Text="Section 1.0">
              
                      <asp:TreeNode Text="Topic 1.0.1"/>
                      <asp:TreeNode Text="Topic 1.0.2"/>
                      <asp:TreeNode Text="Topic 1.0.3"/>
              
                    </asp:TreeNode>
              
                  </asp:TreeNode>
            
                </asp:TreeNode>
        
              </Nodes>
        
            </asp:TreeView>
          
          </td>
          
          <td>
          
            <!-- Set the styles for the leaf nodes declaratively. -->
            <asp:TreeView id="TreeViewResults"
              ExpandDepth="4"   
              runat="server">
         
              <Nodes>
        
                <asp:TreeNode Text="Table of Contents"
                  SelectAction="None">
             
                  <asp:TreeNode Text="Chapter One">
            
                    <asp:TreeNode Text="Section 1.0">
              
                      <asp:TreeNode Text="Topic 1.0.1"/>
                      <asp:TreeNode Text="Topic 1.0.2"/>
                      <asp:TreeNode Text="Topic 1.0.3"/>
              
                    </asp:TreeNode>
              
                  </asp:TreeNode>
            
                </asp:TreeNode>
        
              </Nodes>
        
            </asp:TreeView>
          
          </td>
        
        </tr>
        
        <tr>
        
          <td>
          
            <asp:Button ID="CopyNodeStyleButton" 
              Text="Copy LeafNodeStyle"
              OnClick="Button_Click" 
              runat="server"/>
          
          </td>
          
          <td>
          
             
          
          </td>
        
        </tr>
      
      </table>
       
    </form>
  </body>
</html>

설명

사용 합니다 CopyFrom 지정 된 스타일 속성을 복제 하는 방법 Style 개체는 TreeNodeStyle 이 메서드를 호출 하는 개체입니다.

참고

현재에서 모든 속성 TreeNodeStyle 개체는 지정 된 해당 속성으로 대체 됩니다 Style 개체입니다.

이미 설정 된 모든 값을 바꾸지 않고 스타일 속성을 복사 하려면 사용 된 MergeWith 메서드.

적용 대상

추가 정보