Share via


HtmlTable.Align プロパティ

定義

Web ページ上の他の要素を基準として HtmlTable コントロールの配置を取得または設定します。

public:
 property System::String ^ Align { System::String ^ get(); void set(System::String ^ value); };
public string Align { get; set; }
member this.Align : string with get, set
Public Property Align As String

プロパティ値

Web ページ上の他の要素を基準とする HtmlTable コントロールの配置。 既定値は Empty で、このプロパティが設定されていないことを示します。

次のコード例では、 プロパティを使用 Align して、Web ページ上の他の要素に対するコントロールの HtmlTable 配置を指定する方法を示します。

<%@ Page Language="C#" AutoEventWireup="True" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">

  void Button_Click(Object sender, EventArgs e)
  {

    // Set the HtmlTable properties according to the
    // user selections.
    Table1.CellSpacing = Convert.ToInt32(SpacingSelect.Value);
    Table1.CellPadding = Convert.ToInt32(PaddingSelect.Value);
    Table1.Align = AlignSelect.Value;

  }

</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
   <title>HtmlTable Example</title>
</head>
<body>

   <form id="form1" runat="server">

      <h3>HtmlTable Example</h3>

      <table id="Table1" 
             style="border-width:1; border-color:Black"
             runat="server">

         <tr>
            <th>
               Column 1
            </th>
            <th>
               Column 2
            </th>
            <th>
               Column 3
            </th>
         </tr>
         <tr>
            <td>
               Cell 1
            </td>
            <td>
               Cell 2
            </td>
            <td>
               Cell 3
            </td>
         </tr>
         <tr>
            <td>
               Cell 4
            </td>
            <td>
               Cell 5
            </td>
            <td>
               Cell 6
            </td>
         </tr>

      </table>
      
      <br /><br /><br /><br /><br /><br /><br /><br />
      
      <hr />

      Select the display settings: <br /><br />

      Align:
      <select id="AlignSelect" 
              runat="server">

         <option value="Left">Left</option>
         <option value="Center">Center</option>
         <option value="Right">Right</option>
        
      </select>

        

      CellPadding:
      <select id="PaddingSelect" 
              runat="server">

         <option value="0">0</option>
         <option value="1">1</option>
         <option value="2">2</option>
         <option value="3">3</option>
         <option value="4">4</option>
         <option value="5">5</option>

      </select>

        

      CellSpacing:
      <select id="SpacingSelect" 
              runat="server">

         <option value="0">0</option>
         <option value="1">1</option>
         <option value="2">2</option>
         <option value="3">3</option>
         <option value="4">4</option>
         <option value="5">5</option>

      </select>
       
      <br /><br />
  
      <input type="button" 
             value="Generate Table"
             onserverclick="Button_Click" 
             runat="server"/>

   </form>

</body>
</html>
<%@ Page Language="VB" AutoEventWireup="True" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">

  Sub Button_Click(ByVal sender As Object, ByVal e As EventArgs)

    ' Set the HtmlTable properties according to the
    ' user selections.
    Table1.CellSpacing = CInt(SpacingSelect.Value)
    Table1.CellPadding = CInt(PaddingSelect.Value)
    Table1.Align = AlignSelect.Value

  End Sub

</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
   <title>HtmlTable Example</title>
</head>
<body>

   <form id="form1" runat="server">

      <h3>HtmlTable Example</h3>

      <table id="Table1" 
             style="border-width:1; border-color:Black"
             runat="server">

         <tr>
            <th>
               Column 1
            </th>
            <th>
               Column 2
            </th>
            <th>
               Column 3
            </th>
         </tr>
         <tr>
            <td>
               Cell 1
            </td>
            <td>
               Cell 2
            </td>
            <td>
               Cell 3
            </td>
         </tr>
         <tr>
            <td>
               Cell 4
            </td>
            <td>
               Cell 5
            </td>
            <td>
               Cell 6
            </td>
         </tr>

      </table>
      
      <br /><br /><br /><br /><br /><br /><br /><br />
      
      <hr />

      Select the display settings: <br /><br />

      Align:
      <select id="AlignSelect" 
              runat="server">

         <option value="Left">Left</option>
         <option value="Center">Center</option>
         <option value="Right">Right</option>
        
      </select>

        

      CellPadding:
      <select id="PaddingSelect" 
              runat="server">

         <option value="0">0</option>
         <option value="1">1</option>
         <option value="2">2</option>
         <option value="3">3</option>
         <option value="4">4</option>
         <option value="5">5</option>

      </select>

        

      CellSpacing:
      <select id="SpacingSelect" 
              runat="server">

         <option value="0">0</option>
         <option value="1">1</option>
         <option value="2">2</option>
         <option value="3">3</option>
         <option value="4">4</option>
         <option value="5">5</option>

      </select>
       
      <br /><br />
  
      <input type="button" 
             value="Generate Table"
             onserverclick="Button_Click" 
             runat="server"/>

   </form>

</body>
</html>

注釈

Web ページ上の Align 他の要素に対する HtmlTable コントロールの配置を指定するには、 プロパティを使用します。

Note

このプロパティは、コントロールのセル内のコンテンツの配置を HtmlTable 制御しません。 個々のセルの内容の配置を制御するには、 クラスの Align プロパティと VAlign プロパティを HtmlTableCell 使用します。 クラスの プロパティと VAlign プロパティを使用Alignして、行全体のセルの内容の配置をHtmlTableRow制御することもできます。

次の表に、このプロパティに使用できる値を示します。

[値] 説明
Left Web ページの HtmlTable 左端にコントロールを配置します。
Center Web ページの HtmlTable 中央にコントロールを配置します。
Right Web ページの HtmlTable 右端にコントロールを配置します。

Note

または Right 配置を指定Leftすると、Web ページ上の他の要素がそれぞれコントロールの右または左にHtmlTable折り返されます。 配置を指定 Center した場合、折り返しは行われず、コントロールの下に他の要素が表示されます。

適用対象

こちらもご覧ください