System.Web.UI.WebControls Namespace
Specifies the vertical alignment of an object within a control.
The VerticalAlign enumeration represents the vertical alignment options for an item relative to its container control.
Member Name |
Description |
Bottom |
The contents are aligned with the bottom edge of the enclosing control. |
Middle |
The contents are aligned with the vertical middle of the enclosing control. |
Top |
The contents are aligned with the top edge of the enclosing control. |
NotSet |
The vertical alignment is not set. |
The sample below shows how to programmatically set the VerticalAlign property of a DataGrid at run time, depending on user input. The code also demonstrates how simple it is to retrieve the available system vertical align styles and dynamically add each to a selectable list.
void Page_Load ( Object src, EventArgs e ) {
if ( !IsPostBack ) {
ICollection v_alignEnum =
TypeDescriptor.GetConverter ( typeof ( VerticalAlign ) ).GetStandardValues ( );
foreach ( VerticalAlign v in v_alignEnum ) {
AlignSelect.Items.Add ( v.ToString ( ) );
}
AlignSelect.SelectedIndex = 2;
string query = "SELECT Lastname, Firstname, Address, City, Country FROM Employees";
myGrid.DataSource = fetchData ( query, "northwind" );
myGrid.DataBind ( );
}
myGrid.ItemStyle.VerticalAlign = ( VerticalAlign ) AlignSelect.SelectedIndex;
}
Show me
HorizontalAlign