Share via


HtmlTableCell.BorderColor プロパティ

HtmlTableCell クラスのインスタンスが表すセルの境界線の色を取得または設定します。

Public Property BorderColor As String
[C#]
public string BorderColor {get; set;}
[C++]
public: __property String* get_BorderColor();public: __property void set_BorderColor(String*);
[JScript]
public function get BorderColor() : String;public function set BorderColor(String);

プロパティ値

HtmlTableCell クラスのインスタンスが表すセルの境界線の色。

解説

BorderColor プロパティを使用して、 HtmlTableCell クラスのインスタンスが表すセルの境界線の色を指定します。

使用できる定義済みの 16 個の HTML カラー名を次の一覧に示します。

  • 水色
  • 灰色
  • ライム
  • マゼンタ
  • 濃い青
  • オリーブ
  • シルバー
  • 青緑

16 進数の前にシャープ記号 (#) を付け、 #RRGGBB の形式でカスタム カラーも指定できます。 RRGG 、および BB は、それぞれ色の赤、緑、青の各要素を示す 0 ~ 255 の範囲の 16 進数の値を表します。たとえば、値 #0000FF は青を表します。赤の要素と緑の要素に最小値 (00) を指定し、青の要素には最大値 (FF) を指定します。

使用例

[Visual Basic, C#] BorderColor プロパティを使用して、 HtmlTable コントロールのセルの境界線の色をプログラムで制御する方法の例を次に示します。

 
<%@ Page Language="VB" AutoEventWireup="True" %>

<html>
<head>

   <script runat="server">

      Sub Button_Click(sender As Object, 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).BgColor = BgColorSelect.Value 
               Table1.Rows(i).Cells(j).BorderColor = BorderColorSelect.Value
               Table1.Rows(i).Cells(j).Height = HeightSelect.Value
               Table1.Rows(i).Cells(j).Width = WidthSelect.Value 
            
            Next j

         Next i

      End Sub

   </script>

</head>
<body>

   <form runat="server">

      <h3>HtmlTableCell Example</h3>

      <table id="Table1" 
             Border="1" 
             BorderColor="black" 
             runat="server">

         <tr>
            <td>
               Cell 1.
            </td>
            <td>
               Cell 2.
            </td>
         </tr>
         <tr>
            <td>
               Cell 3.
            </td>
            <td>
               Cell 4.
            </td>
         </tr>

      </table>


      <hr>

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

      BgColor:
      <select id="BgColorSelect" 
              runat="server">

         <option Value="Red">Red</option>
         <option Value="Blue">Blue</option>
         <option Value="Green">Green</option>
         <option Value="Black">Black</option>
         <option Value="White" Selected="True">White</option>
        
      </select>

      &nbsp;&nbsp;

      BorderColor:
      <select id="BorderColorSelect" 
              runat="server">

         <option Value="Red">Red</option>
         <option Value="Blue">Blue</option>
         <option Value="Green">Green</option>
         <option Value="Black" Selected="True">Black</option>
         <option Value="White">White</option>

      </select>

      <br><br>

      Height:
      <select id="HeightSelect" 
              runat="server">

         <option Value="0">0</option>
         <option Value="100">100</option>
         <option Value="150">150</option>
         <option Value="200">200</option>
         <option Value="250">250</option>

      </select>

      &nbsp;&nbsp;

      Width:
      <select id="WidthSelect" 
              runat="server">

         <option Value="0">0</option>
         <option Value="200">200</option>
         <option Value="250">250</option>
         <option Value="300">300</option>
         <option Value="350">350</option>

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

   </form>

</body>
</html>

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

<html>
<head>

   <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].BgColor = BgColorSelect.Value; 
               Table1.Rows[i].Cells[j].BorderColor = BorderColorSelect.Value;
               Table1.Rows[i].Cells[j].Height = HeightSelect.Value;
               Table1.Rows[i].Cells[j].Width = WidthSelect.Value; 
            }

         }

      }

   </script>

</head>
<body>

   <form runat="server">

      <h3>HtmlTableCell Example</h3>

      <table id="Table1" 
             Border="1" 
             BorderColor="black" 
             runat="server">

         <tr>
            <td>
               Cell 1.
            </td>
            <td>
               Cell 2.
            </td>
         </tr>
         <tr>
            <td>
               Cell 3.
            </td>
            <td>
               Cell 4.
            </td>
         </tr>

      </table>


      <hr>

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

      BgColor:
      <select id="BgColorSelect" 
              runat="server">

         <option Value="Red">Red</option>
         <option Value="Blue">Blue</option>
         <option Value="Green">Green</option>
         <option Value="Black">Black</option>
         <option Value="White" Selected="True">White</option>
        
      </select>

      &nbsp;&nbsp;

      BorderColor:
      <select id="BorderColorSelect" 
              runat="server">

         <option Value="Red">Red</option>
         <option Value="Blue">Blue</option>
         <option Value="Green">Green</option>
         <option Value="Black" Selected="True">Black</option>
         <option Value="White">White</option>

      </select>

      <br><br>

      Height:
      <select id="HeightSelect" 
              runat="server">

         <option Value="0">0</option>
         <option Value="100">100</option>
         <option Value="150">150</option>
         <option Value="200">200</option>
         <option Value="250">250</option>

      </select>

      &nbsp;&nbsp;

      Width:
      <select id="WidthSelect" 
              runat="server">

         <option Value="0">0</option>
         <option Value="200">200</option>
         <option Value="250">250</option>
         <option Value="300">300</option>
         <option Value="350">350</option>

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

   </form>

</body>
</html>

[C++, JScript] C++ および JScript のサンプルはありません。Visual Basic および C# のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ

参照

HtmlTableCell クラス | HtmlTableCell メンバ | System.Web.UI.HtmlControls 名前空間 | HtmlTable | BgColor | Height | Width