ContentDirection 枚举

定义

表示在容器控件中显示包含文本的控件的方向。Represents the direction in which to display controls that include text in a container control.

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

字段

LeftToRight 1

从左向右。Left to right.

NotSet 0

未设置。Not set.

RightToLeft 2

从右向左。Right to left.

示例

下面的示例演示如何使用ContentDirection枚举Panel.Direction设置属性。The following example demonstrates how to use the ContentDirection enumeration to set the Panel.Direction property. 使用枚举值填充ListBox控件 ContentDirectionA ListBox control is populated with the ContentDirection enumeration values. 面板中标签和单选按钮的显示方向根据用户从列表框中选择的值更改。The display direction of the label and radio buttons in the panel change based on the value that the user selects from the list box. 由于本示例使用英文文本, 因此, RightToLeft如果选择了值, 文本将在Panel控件的右侧对齐, 但会保留英语文本的从左到右顺序。Because this example uses English text, when the RightToLeft value is selected, the text is justified on the right side of the Panel control, but the left-to-right order of the English text is maintained. 在实际应用程序中, 如果显示的是使用从Panel.Direction左到右RightToLeft顺序的语言文本, 则不能将属性设置为值。In a real-world application, you would not set the Panel.Direction property to the RightToLeft value, if you were displaying text for a language that uses left-to-right order.

<%@ 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枚举表示在容器控件中显示包含文本的控件的方向。The ContentDirection enumeration represents the direction in which to display controls that include text in a container control. 控件 ( Panel如和WebPart控件) ContentDirection具有属性, 这些属性使用枚举值来指定显示包含文本的子控件的方向。Controls such as the Panel and WebPart controls have properties that use the ContentDirection enumeration values to specify the direction in which to display child controls that include text.

如果指定LeftToRight值, 则子控件 (包括文本) 从左到右, 并使文本显示在容器控件的左侧。If you specify the LeftToRight value, child controls that include text display text from left to right and justify the text on the left side of the container control. 如果指定RightToLeft值, 则包含文本的子控件从右到左显示文本, 并在容器控件右侧对齐文本。If you specify the RightToLeft value, child controls that include text display text from right to left and justify the text on the right side of the container control. RightToLeft使用值可以显示从右向左书写的语言 (如阿拉伯语和希伯来语) 的文本。Use the RightToLeft value to display text for languages that are written from right to left, such as Arabic and Hebrew.

适用于

另请参阅