DesignerAutoFormatStyle.VerticalAlign 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取或设置关联控件内容的垂直对齐方式。
public:
property System::Web::UI::WebControls::VerticalAlign VerticalAlign { System::Web::UI::WebControls::VerticalAlign get(); void set(System::Web::UI::WebControls::VerticalAlign value); };
public System.Web.UI.WebControls.VerticalAlign VerticalAlign { get; set; }
member this.VerticalAlign : System.Web.UI.WebControls.VerticalAlign with get, set
Public Property VerticalAlign As VerticalAlign
属性值
VerticalAlign 值之一。 默认值为 NotSet
。
示例
下面的代码示例演示如何使用 DesignerAutoFormat 对象和 Style 属性将格式应用于控件。
// Applies styles based on the Name of the AutoFormat
public override void Apply(Control inLabel)
{
if (inLabel is IndentLabel)
{
IndentLabel ctl = (IndentLabel)inLabel;
// Apply formatting according to the Name
if (this.Name == "MyClassic")
{
// For MyClassic, apply style elements directly to the control
ctl.ForeColor = Color.Gray;
ctl.BackColor = Color.LightGray;
ctl.Font.Size = FontUnit.XSmall;
ctl.Font.Name = "Verdana,Geneva,Sans-Serif";
}
else if (this.Name == "MyBright")
{
// For MyBright, apply style elements to the Style property
this.Style.ForeColor = Color.Maroon;
this.Style.BackColor = Color.Yellow;
this.Style.Font.Size = FontUnit.Medium;
// Merge the AutoFormat style with the control's style
ctl.MergeStyle(this.Style);
}
else
{
// For the Default format, apply style elements to the control
ctl.ForeColor = Color.Black;
ctl.BackColor = Color.Empty;
ctl.Font.Size = FontUnit.XSmall;
}
}
}
' Applies styles based on the Name of the AutoFormat
Public Overrides Sub Apply(ByVal inLabel As Control)
If TypeOf inLabel Is IndentLabel Then
Dim ctl As IndentLabel = CType(inLabel, IndentLabel)
' Apply formatting according to the Name
If Me.Name.Equals("MyClassic") Then
' For MyClassic, apply style elements directly to the control
ctl.ForeColor = Color.Gray
ctl.BackColor = Color.LightGray
ctl.Font.Size = FontUnit.XSmall
ctl.Font.Name = "Verdana,Geneva,Sans-Serif"
ElseIf Me.Name.Equals("MyBright") Then
' For MyBright, apply style elements to the Style object
Me.Style.ForeColor = Color.Maroon
Me.Style.BackColor = Color.Yellow
Me.Style.Font.Size = FontUnit.Medium
' Merge the AutoFormat style with the control's style
ctl.MergeStyle(Me.Style)
Else
' For the Default format, apply style elements to the control
ctl.ForeColor = Color.Black
ctl.BackColor = Color.Empty
ctl.Font.Size = FontUnit.XSmall
End If
End If
End Sub
注解
使用属性 VerticalAlign 指定关联控件内容的垂直对齐方式。 VerticalAlign如果该属性不适用于关联的控件,则忽略该设置。 有关垂直对齐枚举的已定义值,请参阅 VerticalAlign。