Panel.Direction 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取或设置在 Panel 控件中显示包含文本的控件的方向。
public:
virtual property System::Web::UI::WebControls::ContentDirection Direction { System::Web::UI::WebControls::ContentDirection get(); void set(System::Web::UI::WebControls::ContentDirection value); };
public virtual System.Web.UI.WebControls.ContentDirection Direction { get; set; }
member this.Direction : System.Web.UI.WebControls.ContentDirection with get, set
Public Overridable Property Direction As ContentDirection
属性值
ContentDirection 枚举值之一。 默认值为 NotSet
。
示例
下面的代码示例演示如何以编程方式设置 Direction 属性。 ListBox使用枚举值填充ContentDirection控件。 根据用户从列表框中选择的值更改面板中的标签和单选按钮的显示方向。 请注意,此示例使用英语文本。 因此,选择值时 RightToLeft
,文本在控件右侧 Panel 对齐,但保留英文文本的从左到右的顺序。 在实际应用程序中,如果显示从左到右的语言的文本,则不会将 Direction 属性设置为该属性 RightToLeft
。
备注
下面的代码示例使用单文件代码模型,如果直接复制到代码隐藏文件中,可能无法正常工作。 必须将此代码示例复制到扩展名为 .aspx 的空文本文件中。 有关Web Forms代码模型的详细信息,请参阅 ASP.NET Web Forms页代码模型。
<%@ 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>
注解
使用 Direction 属性指定控件的显示方向,这些控件包含控件中的 Panel 文本。 此属性是使用枚举值之一设置的 ContentDirection 。 下表列出了可能的值。
值 | 说明 |
---|---|
NotSet |
未设置内容方向。 |
LeftToRight |
内容方向从左到右。 |
RightToLeft |
内容方向从右到左。 |
如果指定 LeftToRight
,则包含从左到右的文本显示的子控件。 如果指定 RightToLeft
,则包含从右到左显示文本的子控件。 用于 RightToLeft
显示从右到左写入的语言的文本,例如阿拉伯语或希伯来语。
备注
此属性仅在支持 HTML 4.0 或更高版本的浏览器中受支持。