ContentDirection 列舉

定義

表示在容器 (Container) 控制項中顯示包含文字之控制項的方向。

public enum class ContentDirection
public enum ContentDirection
type ContentDirection = 
Public Enum ContentDirection
繼承
ContentDirection

欄位

LeftToRight 1

由左至右。

NotSet 0

未設定。

RightToLeft 2

由右至左。

範例

下列範例示範如何使用 ContentDirection 列舉來設定 Panel.Direction 屬性。 控制項 ListBox 會填入 ContentDirection 列舉值。 面板中標籤和選項按鈕的顯示方向會根據使用者從清單方塊中選取的值而變更。 因為這個範例使用英文文字,所以選取值時 RightToLeft ,文字會靠右對齊控制項的右邊 Panel ,但會維護英文文字的由左至右順序。 在真實世界應用程式中,如果您顯示使用由左至右順序之語言的文字,則不會將 Panel.Direction 屬性 RightToLeft 設定為 值。

<%@ 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>
    <title>Panel.Direction Property Example</title>
<script runat="server">
          
        Sub ListBox1_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs)

            ' Determine which list item was clicked.
            ' Change the display direction of content in the panel.
            Select Case (ListBox1.SelectedIndex)
                Case 0
                    Panel1.Direction = ContentDirection.NotSet
                Case 1
                    Panel1.Direction = ContentDirection.LeftToRight
                Case 2
                    Panel1.Direction = ContentDirection.RightToLeft
                Case Else
                    Throw New Exception("You did not select a valid list item.")
            End Select

        End Sub
     
    </script>
</head>
<body>
    <form id="Form1" runat="server">
        
        <h3>Panel.Direction Property Example</h3>
        
        <h4>Select the content display direction for the 
        controls in the panel.</h4>
        
        <asp:ListBox ID="ListBox1"
            Rows="3"
            AutoPostBack="True"
            SelectionMode="Single"
            OnSelectedIndexChanged="ListBox1_SelectedIndexChanged"
            runat="server">
                <asp:ListItem>NotSet</asp:ListItem>
            <asp:ListItem>LeftToRight</asp:ListItem> 
            <asp:ListItem>RightToLeft</asp:ListItem>                               
        </asp:ListBox>
            
        <hr />              
        
        <asp:Panel ID="Panel1"
            Height="100px"
            Width="300px"
            BackColor="Aqua"           
            runat="server">            
            
            <asp:Label ID="Label1"
                Text = "Select a programming language"
                runat="server">              
            </asp:Label><br /><br />
            
            <asp:RadioButton id="Radio1"
                Text="C#" 
                Checked="False" 
                GroupName="RadioGroup1" 
                runat="server">
            </asp:RadioButton><br />

            <asp:RadioButton id="Radio2"
                Text="Visual Basic" 
                Checked="False" 
                GroupName="RadioGroup1" 
                runat="server">
            </asp:RadioButton><br />
                   
            <asp:RadioButton id="Radio3"
                Text="C++" 
                Checked="False" 
                GroupName="RadioGroup1" 
                runat="server">
            </asp:RadioButton><br />           
            
        </asp:Panel>           
         
    </form>
</body>
</html>

備註

列舉 ContentDirection 表示顯示控制項在容器控制項中包含文字的方向。 和 WebPart 控制項之類的 Panel 控制項具有使用 ContentDirection 列舉值的屬性來指定顯示包含文字之子控制項的方向。

如果您指定 LeftToRight 值,則包含文字的子控制項會從左至右顯示文字,並對齊容器控制項左側的文字。 如果您指定 RightToLeft 值,則包含文字的子控制項會從右至左顯示文字,並對齊容器控制項右側的文字。 RightToLeft使用 值來顯示從右至左撰寫之語言的文字,例如阿拉伯文和希伯來文。

適用於

另請參閱