Export (0) Print
Expand All

TreeView.HoverNodeStyle Property

Gets a reference to the TreeNodeStyle object that allows you to set the appearance of a node when the mouse pointer is positioned over it.

Namespace: System.Web.UI.WebControls
Assembly: System.Web (in system.web.dll)

public Style HoverNodeStyle { get; }
/** @property */
public Style get_HoverNodeStyle ()

public function get HoverNodeStyle () : Style

Not applicable.

Property Value

A reference to the TreeNodeStyle that represents the style of a node when the mouse pointer is positioned over it.

Use the HoverNodeStyle property to control the appearance of a node when the mouse pointer is positioned over it. This property is read-only; however, you can set the properties of the TreeNodeStyle object that it returns. The properties can be set declaratively in the form Property-Subproperty, where Subproperty is a property of the TreeNodeStyle object (for example, HoverNodeStyle-ForeColor). The properties can also be set programmatically in the form Property.Subproperty (for example, HoverNodeStyle.ForeColor). This feature is supported only on script-capable clients.

NoteNote:

To use the HoverNodeStyle property, you must include a <head> element with a runat="server" attribute.

Common settings usually include a custom background color, foreground color, font properties, and node spacing. Style properties are applied in the following order:

  1. NodeStyle.

  2. RootNodeStyle, ParentNodeStyle, or LeafNodeStyle, depending on the node type. If the LevelStyles collection is defined, it is applied at this time, overriding the other node style properties.

  3. SelectedNodeStyle.

  4. HoverNodeStyle.

NoteNote:

The style settings for the HoverNodeStyle property override any corresponding node style settings that are in the NodeStyle, RootNodeStyle, ParentNodeStyle, LeafNodeStyle, or SelectedNodeStyle property.

The HoverNodeStyle property is not rendered for a node with its SelectAction property set to TreeNodeSelectAction.None.

Unlike the ParentNodeStyle and the LeafNodeStyle properties, which are TreeNodeStyle objects, the HoverNodeStyle property is a Style object.

The following code example demonstrates how to use the HoverNodeStyle property to control the appearance of a node when the mouse pointer is positioned over it. For this example to work, you must include a <head> element with a runat="server" attribute.


<%@ 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>


Windows 98, Windows Server 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0

Community Additions

ADD
Show:
© 2014 Microsoft