asp.net.ph

HorizontalAlign Enumeration

System.Web.UI.WebControls Namespace


Specifies the horizontal alignment of an object within a control.

Remarks

The HorizontalAlign enumeration represents the horizontal alignment options for an item relative to its container control.

Members


Member Name Description
Center The contents of a container are centered.
Justify The contents of a container are uniformly spread out and aligned with both the left and right margins.
Left The contents of a container are left justified.
NotSet The horizontal alignment is not set.
Right The contents of a container are right justified.

Example

The sample below shows how to programmatically set the HorizontalAlign property of a DataGrid 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;

      string query = "SELECT Lastname, Firstname, Address, City, Country FROM Employees";
      myGrid.DataSource = fetchData ( query, "northwind" );
      myGrid.DataBind ( );
   }
   myGrid.ItemStyle.HorizontalAlign = ( HorizontalAlign ) AlignSelect.SelectedIndex;
}
  C# VB

 Show me 

See Also

VerticalAlign Skip Navigation Links




Home
Suggested Reading


Previous page Back to top Next page

© 2000-2010 Rey Nuñez All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note

You can help support asp.net.ph