Menu.DynamicVerticalOffset 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得或設定動態選單相對於父選單項目垂直移動的像素數。
public:
property int DynamicVerticalOffset { int get(); void set(int value); };
public int DynamicVerticalOffset { get; set; }
member this.DynamicVerticalOffset : int with get, set
Public Property DynamicVerticalOffset As Integer
屬性值
動態選單相對於父選單項目垂直移動的像素數。 預設值是 0。
範例
以下程式碼範例示範如何利用該 DynamicVerticalOffset 屬性將動態選單從父選單項目頂部向下移動 10 像素。
<%@ 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 DynamicHorizontalOffset and DynamicVerticalOffset Example</title>
</head>
<body>
<form id="form1" runat="server">
<h3>Menu DynamicHorizontalOffset and DynamicVerticalOffset Example</h3>
<asp:menu id="NavigationMenu"
dynamichorizontaloffset="5"
dynamicverticaloffset="10"
staticdisplaylevels="1"
orientation="Vertical"
runat="server">
<dynamicmenuitemstyle BackColor="Silver"/>
<staticmenuitemstyle BackColor="Gray"/>
<items>
<asp:menuitem navigateurl="Home.aspx"
text="Home"
tooltip="Home">
<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="Movies"
tooltip="Movies">
<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="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 DynamicHorizontalOffset and DynamicVerticalOffset Example</title>
</head>
<body>
<form id="form1" runat="server">
<h3>Menu DynamicHorizontalOffset and DynamicVerticalOffset Example</h3>
<asp:menu id="NavigationMenu"
dynamichorizontaloffset="5"
dynamicverticaloffset="10"
staticdisplaylevels="1"
orientation="Vertical"
runat="server">
<dynamicmenuitemstyle BackColor="Silver"/>
<staticmenuitemstyle BackColor="Gray"/>
<items>
<asp:menuitem navigateurl="Home.aspx"
text="Home"
tooltip="Home">
<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="Movies"
tooltip="Movies">
<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>
備註
使用該 DynamicVerticalOffset 屬性來調整動態選單相對於父選單項目的垂直位置。 此特性會根據控制項是 Menu 垂直顯示還是水平顯示(依屬性 Orientation 指定)而不同影響動態選單的位置。 下表說明這些差異。
| 導覽 | 說明 |
|---|---|
| 水平 | 預設情況下,動態選單會直接顯示在其父選單項目下方,中間沒有空格。 設定此屬性可控制動態選單與其父選單項目之間的垂直間距。 |
| 垂直 | 預設情況下,動態選單項目會顯示在其父選單項目旁邊,且頂部邊緣對齊。 設定此屬性會使動態選單位置從該基底位置垂直移動。 |
備註
你可以將這個屬性設為負值,讓動態選單朝負面方向移動。 如果你顯示的是水平選單,負值會導致動態選單及其父選單項目重疊。