TreeView.HoverNodeStyle 属性    
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取对 TreeNodeStyle 对象的引用,该对象可用于设置当鼠标指针停在一个节点上时该节点的外观。
public:
 property System::Web::UI::WebControls::Style ^ HoverNodeStyle { System::Web::UI::WebControls::Style ^ get(); };[System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)]
public System.Web.UI.WebControls.Style HoverNodeStyle { get; }[<System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)>]
member this.HoverNodeStyle : System.Web.UI.WebControls.StylePublic ReadOnly Property HoverNodeStyle As Style属性值
对 TreeNodeStyle 的一个引用,表示鼠标指针停在一个节点上时该节点的样式。
- 属性
示例
下面的代码示例演示如何在鼠标指针放置在节点上方时使用 HoverNodeStyle 属性来控制节点的外观。 若要使此示例正常工作,必须包含具有 <head> 属性的 runat="server" 元素。
<%@ 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" >
  <!-- The HoverNodeStyle property needs this head element to work. -->
  <head runat="server">
    <title>TreeView HoverNodeStyle Example</title>
</head>
  <body>
    <form id="form1" runat="server">
    
      <h3>TreeView HoverNodeStyle Example</h3>
      
      <!-- Declaratively set the HoverNodeStyle settings. --> 
      <asp:TreeView id="LinksTreeView"
        HoverNodeStyle-ForeColor="Green"
        runat="server">
         
        <Nodes>
        
          <asp:TreeNode Value="Home" 
            NavigateUrl="Home.aspx" 
            Text="Home"
            Target="Content" 
            Expanded="True">
             
            <asp:TreeNode Value="Page 1" 
              NavigateUrl="Page1.aspx" 
              Text="Page1"
              Target="Content">
               
              <asp:TreeNode Value="Section 1" 
                NavigateUrl="Section1.aspx" 
                Text="Section 1"
                Target="Content"/>
                 
            </asp:TreeNode>              
            
            <asp:TreeNode Value="Page 2" 
              NavigateUrl="Page2.aspx"
              Text="Page 2"
              Target="Content">
               
            </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" >
  <!-- The HoverNodeStyle property needs this head element to work. -->
  <head runat="server">
    <title>TreeView HoverNodeStyle Example</title>
</head>
  <body>
    <form id="form1" runat="server">
    
      <h3>TreeView HoverNodeStyle Example</h3>
      
      <!-- Declaratively set the HoverNodeStyle settings. --> 
      <asp:TreeView id="LinksTreeView"
        HoverNodeStyle-ForeColor="Green"
        runat="server">
         
        <Nodes>
        
          <asp:TreeNode Value="Home" 
            NavigateUrl="Home.aspx" 
            Text="Home"
            Target="Content" 
            Expanded="True">
             
            <asp:TreeNode Value="Page 1" 
              NavigateUrl="Page1.aspx" 
              Text="Page1"
              Target="Content">
               
              <asp:TreeNode Value="Section 1" 
                NavigateUrl="Section1.aspx" 
                Text="Section 1"
                Target="Content"/>
                 
            </asp:TreeNode>              
            
            <asp:TreeNode Value="Page 2" 
              NavigateUrl="Page2.aspx"
              Text="Page 2"
              Target="Content">
               
            </asp:TreeNode> 
            
          </asp:TreeNode>
        
        </Nodes>
        
      </asp:TreeView>
    </form>
  </body>
</html>
注解
当 HoverNodeStyle 鼠标指针放置在节点上方时,使用该属性来控制节点的外观。 此属性为只读;但是,可以设置它返回的对象的属性 TreeNodeStyle 。 可以在窗体 Property-Subproperty中以声明方式设置属性,例如 Subproperty ,对象的属性 TreeNodeStyle () HoverNodeStyle-ForeColor 。 还可以以编程方式在窗体 Property.Subproperty 中设置属性,例如 HoverNodeStyle.ForeColor)  (。 此功能仅在支持脚本的客户端上受支持。
备注
若要使用该 HoverNodeStyle 属性,必须包含具有 <head> 属性的 runat="server" 元素。
常见设置通常包括自定义背景色、前景颜色、字体属性和节点间距。 样式属性按以下顺序应用:
- RootNodeStyle、 ParentNodeStyle或 LeafNodeStyle,具体取决于节点类型。 LevelStyles如果定义了集合,则此时应用该集合,重写其他节点样式属性。 
备注
属性的HoverNodeStyle样式设置将替代位于 、RootNodeStyle、ParentNodeStyle或LeafNodeStyleSelectedNodeStyle属性中的任何NodeStyle相应节点样式设置。
The HoverNodeStyle property is not rendered for a node with its SelectAction property set to TreeNodeSelectAction.None.
ParentNodeStyle LeafNodeStyle与对象和TreeNodeStyle属性不同,属性HoverNodeStyle是对象Style。