HtmlTableCell.VAlign プロパティ

定義

HtmlTableCell クラスのインスタンスで表されるセルの内容の垂直方向の配置を取得または設定します。

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

プロパティ値

HtmlTableCell のインスタンスで表されるセルの内容の垂直方向の配置。 既定値は Empty で、このプロパティが設定されていないことを示します。

次のコード例では、 プロパティを VAlign 使用して、コントロール内のセルの内容の垂直方向の配置をプログラムで制御する方法を 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)
  {

    // Iterate through the rows of the table.
    for (int i = 0; i <= Table1.Rows.Count - 1; i++)
    {

      // Iterate through the cells of a row.
      for (int j = 0; j <= Table1.Rows[i].Cells.Count - 1; j++)
      {
        // Update the properties of each cell. 
        Table1.Rows[i].Cells[j].Align = AlignSelect.Value;
        Table1.Rows[i].Cells[j].NoWrap = Convert.ToBoolean(NoWrapSelect.Value);
        Table1.Rows[i].Cells[j].VAlign = VAlignSelect.Value;
      }

    }

  }

</script>

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

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

      <h3>HtmlTableCell Example</h3>

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

         <tr>
            <td>
               Here is some content for Cell 1.
            </td>
            <td>
               Here is some content for Cell 2.
            </td>
         </tr>
         <tr>
            <td style="width:100; height:100">
               Here is some content for Cell 3.
            </td>
            <td style="width:100; height:100">
               Here is some content for Cell 4.
            </td>
         </tr>

      </table>

      <hr />

      Select the display settings for the cells in the table: <br /><br />

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

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

        

      NoWrap:
      <select id="NoWrapSelect" 
              runat="server">

         <option value="true">True</option>
         <option value="false" selected="selected">False</option>

      </select>

        

      VAlign:
      <select id="VAlignSelect" 
              runat="server">

         <option value="Top">Top</option>
         <option value="Middle" selected="selected">Middle</option>
         <option value="Bottom">Bottom</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)

     Dim i As Integer
     Dim j As Integer

     ' Iterate through the rows of the table.
     For i = 0 To Table1.Rows.Count - 1

       ' Iterate through the cells of a row.
       For j = 0 To Table1.Rows(i).Cells.Count - 1
           
         ' Update the properties of each cell. 
         Table1.Rows(i).Cells(j).Align = AlignSelect.Value
         Table1.Rows(i).Cells(j).NoWrap = Convert.ToBoolean(NoWrapSelect.Value)
         Table1.Rows(i).Cells(j).VAlign = VAlignSelect.Value

       Next j

     Next i

   End Sub

</script>

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

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

      <h3>HtmlTableCell Example</h3>

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

         <tr>
            <td>
               Here is some content for Cell 1.
            </td>
            <td>
               Here is some content for Cell 2.
            </td>
         </tr>
         <tr>
            <td style="width:100; height:100">
               Here is some content for Cell 3.
            </td>
            <td style="width:100; height:100">
               Here is some content for Cell 4.
            </td>
         </tr>

      </table>

      <hr />

      Select the display settings for the cells in the table: <br /><br />

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

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

        

      NoWrap:
      <select id="NoWrapSelect" 
              runat="server">

         <option value="true">True</option>
         <option value="false" selected="selected">False</option>

      </select>

        

      VAlign:
      <select id="VAlignSelect" 
              runat="server">

         <option value="Top">Top</option>
         <option value="Middle" selected="selected">Middle</option>
         <option value="Bottom">Bottom</option>

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

   </form>

</body>
</html>

注釈

クラスの VAlign インスタンスで表されるセル内のコンテンツの垂直方向の配置を指定するには、 プロパティを HtmlTableCell 使用します。

Note

このプロパティを設定すると、 クラスのインスタンスによって表されるセルにのみ影響します HtmlTableCell 。 テーブル内の行全体のセルに同じ垂直方向の配置を適用するには、 クラスのインスタンスによって表される行の プロパティをHtmlTableRow設定VAlignします。

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

[値] 説明
Top セルの内容をセルの上端に合わせます。
Middle セルの内容をセルの中央に配置します。
Bottom セルの内容をセルの下端に合わせます。

Note

このプロパティの値として を使用 BaseLine することもできます。 ただし、すべてのブラウザーでこの機能がサポートされているわけではありません。

適用対象

こちらもご覧ください