MenuItemStyle.HorizontalPadding Egenskap

Definition

Hämtar eller anger mängden utrymme till vänster och höger om menyalternativets text.

public:
 property System::Web::UI::WebControls::Unit HorizontalPadding { System::Web::UI::WebControls::Unit get(); void set(System::Web::UI::WebControls::Unit value); };
public System.Web.UI.WebControls.Unit HorizontalPadding { get; set; }
member this.HorizontalPadding : System.Web.UI.WebControls.Unit with get, set
Public Property HorizontalPadding As Unit

Egenskapsvärde

Mängden utrymme (i bildpunkter) till vänster och höger om menyalternativets text. Standardvärdet är 0.

Undantag

Det valda värdet är av typen Percentage.

-eller-

Det valda värdet är mindre än 0.

Exempel

Följande kodexempel visar hur du använder HorizontalPadding egenskapen för att fylla det vågräta avståndet runt texten i ett menyalternativ med 10 bildpunkter.


<%@ 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>MenuItemStyle HorizontalPadding Example</title>
</head>
<body>
    <form id="form1" runat="server">
    
      <h3>MenuItemStyle HorizontalPadding Example</h3>
      
      <asp:menu id="NavigationMenu"
        staticdisplaylevels="2"
        staticsubmenuindent="10" 
        orientation="Vertical"
        runat="server">
        
        <staticmenuitemstyle horizontalpadding="10"
          backcolor="LightBlue"/>
        <dynamicmenuitemstyle horizontalpadding="10"
          backcolor="LightBlue"/>
      
        <items>
          <asp:menuitem text="Home"
            tooltip="Home">
            <asp:menuitem text="Music"
              tooltip="Music">
              <asp:menuitem text="Classical"
                tooltip="Classical"/>
              <asp:menuitem text="Rock"
                tooltip="Rock"/>
              <asp:menuitem text="Jazz"
                tooltip="Jazz"/>
            </asp:menuitem>
            <asp:menuitem text="Movies"
              tooltip="Movies">
              <asp:menuitem text="Action"
                tooltip="Action"/>
              <asp:menuitem text="Drama"
                tooltip="Drama"/>
              <asp:menuitem text="Musical"
                tooltip="Musical"/>
            </asp:menuitem>
          </asp:menuitem>
        </items>
      
      </asp:menu>

    </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>MenuItemStyle HorizontalPadding Example</title>
</head>
<body>
    <form id="form1" runat="server">
    
      <h3>MenuItemStyle HorizontalPadding Example</h3>
      
      <asp:menu id="NavigationMenu"
        staticdisplaylevels="2"
        staticsubmenuindent="10" 
        orientation="Vertical"
        runat="server">
        
        <staticmenuitemstyle horizontalpadding="10"
          backcolor="LightBlue"/>
        <dynamicmenuitemstyle horizontalpadding="10"
          backcolor="LightBlue"/>
      
        <items>
          <asp:menuitem text="Home"
            tooltip="Home">
            <asp:menuitem text="Music"
              tooltip="Music">
              <asp:menuitem text="Classical"
                tooltip="Classical"/>
              <asp:menuitem text="Rock"
                tooltip="Rock"/>
              <asp:menuitem text="Jazz"
                tooltip="Jazz"/>
            </asp:menuitem>
            <asp:menuitem text="Movies"
              tooltip="Movies">
              <asp:menuitem text="Action"
                tooltip="Action"/>
              <asp:menuitem text="Drama"
                tooltip="Drama"/>
              <asp:menuitem text="Musical"
                tooltip="Musical"/>
            </asp:menuitem>
          </asp:menuitem>
        </items>
      
      </asp:menu>

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

Kommentarer

Använd egenskapen HorizontalPadding för att styra mängden vågrätt utrymme runt texten i menyalternativet MenuItemStyle som objektet tillämpas på. Det här utrymmet infogas mellan textens vänstra kant och textområdets kantlinje och mellan textens högra kant och textens kantlinje. Använd egenskapen om VerticalPadding du vill styra det lodräta avståndet.

Gäller för

Se även