System.Web.UI.WebControls Namespace TableRow Class
Sets or retrieves the horizontal alignment of the contents in the row.
Inline |
<asp:tablerow horizontalalign = enumValue ... > |
Script |
TableRow.HorizontalAlign [ = enumValue ] |
The property is read/write with a default value of NotSet.
Use the HorizontalAlign property to specify the horizontal alignment of the contents of the row. This property is set with one of the HorizontalAlign enumeration values.
The sample below shows how to programmatically set the HorizontalAlign property of a TableRow at run time, depending on user input. The code also demonstrates how simple it is to retrieve the available system horizontal align styles and dynamically add each to a selectable list.
void Page_Load ( Object src, EventArgs e ) {
if ( !IsPostBack ) {
ICollection h_aligns =
TypeDescriptor.GetConverter ( typeof ( HorizontalAlign ) ).GetStandardValues ( );
foreach ( HorizontalAlign h in h_aligns ) {
AlignSelect.Items.Add ( h.ToString ( ) );
}
AlignSelect.SelectedIndex = 2;
}
myRow.HorizontalAlign = ( HorizontalAlign ) AlignSelect.SelectedIndex;
}
Sub Page_Load ( src As Object, e As EventArgs )
If Not IsPostBack Then
Dim h_aligns As ICollection = _
TypeDescriptor.GetConverter ( GetType ( HorizontalAlign ) ).GetStandardValues ( )
Dim h As HorizontalAlign
For Each h In h_aligns
AlignSelect.Items.Add ( h.ToString ( ) )
Next h
AlignSelect.SelectedIndex = 2
End If
myRow.HorizontalAlign = CType ( AlignSelect.SelectedIndex, HorizontalAlign )
End Sub |
|
C# |
VB |
TableRow Members