MenuItem.Selectable Propriedade

Definição

Obtém ou define um valor que indica se o objeto MenuItem pode ser selecionado ou se é “clicável”.Gets or sets a value that indicates whether the MenuItem object can be selected, or is "clickable."

public:
 property bool Selectable { bool get(); void set(bool value); };
[System.ComponentModel.Browsable(true)]
public bool Selectable { get; set; }
[<System.ComponentModel.Browsable(true)>]
member this.Selectable : bool with get, set
Public Property Selectable As Boolean

Valor da propriedade

Boolean

true se o item de menu puder ser selecionado; caso contrário, false.true if the menu item can be selected; otherwise, false.

Atributos

Exemplos

O exemplo a seguir demonstra como um item de menu com a Selectable propriedade definida como false aparece e funciona em um menu.The following example demonstrates how a menu item with the Selectable property set to false appears and functions in a menu.


<%@ 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>Menu Selectable and Enabled properties Example</title>
</head>
<body>
    <form id="form1" runat="server">
    
      <h3>Menu Selectable and Enabled properties Example</h3>
    Note that Home, set to Selectable=false, is unselectable, but still shows all child items.<br />
    Movies, set to Enabled=false, is unselectable, is greyed out, and does not show child items. <br />
      <asp:menu id="NavigationMenu"
        staticdisplaylevels="1"
        staticsubmenuindent="10" 
        orientation="Vertical"
        target="_blank"  
        runat="server">
        
        <dynamicmenustyle backcolor="LightSkyBlue"
          forecolor="Black"
          borderstyle="Solid"
          borderwidth="1"
          bordercolor="Black" />
      
        <items>
          <asp:menuitem navigateurl="Home.aspx" 
            text="Non-Selectable"
            tooltip="Non-Selectable"
              Selectable="false">
            <asp:menuitem navigateurl="Music.aspx"
              text="Music"
              tooltip="Music">
              <asp:menuitem navigateurl="Classical.aspx" 
                text="Classical"
                tooltip="Classical"/>
              <asp:menuitem navigateurl="Rock.aspx"
                text="Rock"
                tooltip="Rock"/>
              <asp:menuitem navigateurl="Jazz.aspx"
                text="Jazz"
                tooltip="Jazz"/>
            </asp:menuitem>
            <asp:menuitem navigateurl="Movies.aspx"
              text="Disabled"
              tooltip="Disabled"
              Enabled="false">
              <asp:menuitem navigateurl="Action.aspx"
                text="Action"
                tooltip="Action"/>
                 
              <asp:menuitem navigateurl="Drama.aspx"
                text="Drama"
                tooltip="Drama"/>
              <asp:menuitem navigateurl="Musical.aspx"
                text="Musical"
                tooltip="Musical"/>
            </asp:menuitem>
          </asp:menuitem>
        </items>
      
      </asp:menu>

    </form>
  </body>
</html>


<%@ 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>Menu Selectable and Enabled properties Example</title>
</head>
<body>
    <form id="form1" runat="server">
    
      <h3>Menu Selectable and Enabled properties Example</h3>
    Note that Home, set to Selectable=false, is unselectable, but still shows all child items.<br />
    Movies, set to Enabled=false, is unselectable, is greyed out, and does not show child items. <br />
      <asp:menu id="NavigationMenu"
        staticdisplaylevels="1"
        staticsubmenuindent="10" 
        orientation="Vertical"
        target="_blank"  
        runat="server">
        
        <dynamicmenustyle backcolor="LightSkyBlue"
          forecolor="Black"
          borderstyle="Solid"
          borderwidth="1"
          bordercolor="Black" />
      
        <items>
          <asp:menuitem navigateurl="Home.aspx" 
            text="Non-Selectable"
            tooltip="Non-Selectable"
              Selectable="false">
            <asp:menuitem navigateurl="Music.aspx"
              text="Music"
              tooltip="Music">
              <asp:menuitem navigateurl="Classical.aspx" 
                text="Classical"
                tooltip="Classical"/>
              <asp:menuitem navigateurl="Rock.aspx"
                text="Rock"
                tooltip="Rock"/>
              <asp:menuitem navigateurl="Jazz.aspx"
                text="Jazz"
                tooltip="Jazz"/>
            </asp:menuitem>
            <asp:menuitem navigateurl="Movies.aspx"
              text="Disabled"
              tooltip="Disabled"
              Enabled="false">
              <asp:menuitem navigateurl="Action.aspx"
                text="Action"
                tooltip="Action"/>
                 
              <asp:menuitem navigateurl="Drama.aspx"
                text="Drama"
                tooltip="Drama"/>
              <asp:menuitem navigateurl="Musical.aspx"
                text="Musical"
                tooltip="Musical"/>
            </asp:menuitem>
          </asp:menuitem>
        </items>
      
      </asp:menu>

    </form>
  </body>
</html>

Comentários

Quando essa propriedade é definida como false em um item de menu, nenhuma ação ocorre quando o item de menu é clicado (selecionado).When this property is set to false on a menu item, no action occurs when the menu item is clicked (selected). A imagem pop-out que indica itens de menu filho para o item de menu, se houver, ainda será mostrada e estará disponível.The pop-out image indicating child menu items for the menu item, if one exists, is still shown and available.

Se você não quiser que nenhum item de menu filho apareça para um item de menu, defina a Enabled propriedade como false .If you do not want any child menu items to appear for a menu item, set the Enabled property to false.

Selectable aplica-se somente a itens de menu que podem ser selecionados, no sentido de que clicar em um item de menu é Postado e define esse item no estado selecionado.Selectable applies only to menu items that can be selected, in the sense that clicking a menu item posts back and sets that item in the selected state. Observe que um item de menu que não pode ser selecionado ainda está formatado como um link.Note that a menu item that cannot be selected is still formatted as a link. Isso é por motivos de acessibilidade, para que o item de menu possa fazer com que uma ação ocorra.This is for accessibility reasons, so that the menu item can cause an action to occur. Além disso, um item de menu, mesmo que não possa ser selecionado, pode ter itens de menu filho que podem ser selecionados ou que precisam ser exibidos.Also, a menu item, even if it cannot be selected, may have child menu items that can be selected or that need to be displayed.

Se você quiser impedir que um usuário clique em um item de menu, siga um destes procedimentos:If you want to prevent a user from clicking a menu item, do one of the following:

Aplica-se a

Confira também