HtmlTableCell.BorderColor 属性
定义
获取或设置由 HtmlTableCell 类的实例所表示的单元格的边框颜色。Gets or sets the border color of the cell represented by an instance of the HtmlTableCell class.
public:
property System::String ^ BorderColor { System::String ^ get(); void set(System::String ^ value); };
public string BorderColor { get; set; }
member this.BorderColor : string with get, set
Public Property BorderColor As String
属性值
HtmlTableCell 的实例所表示的单元格的边框颜色。The border color of the cell represented by an instance of HtmlTableCell.
示例
下面的代码示例演示如何使用属性以 BorderColor 编程方式控制控件中单元格的边框颜色 HtmlTable 。The following code example demonstrates how to use the BorderColor property to programmatically control the border color of the cells in an HtmlTable control.
<%@ 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].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>
<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>
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="selected">White</option>
</select>
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="selected">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>
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>
<%@ 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).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>
<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>
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="selected">White</option>
</select>
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="selected">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>
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>
注解
使用 BorderColor 属性可以指定由类的实例所表示的单元格的边框颜色 HtmlTableCell 。Use the BorderColor property to specify the border color of the cell represented by an instance of the HtmlTableCell class. 您可以按名称指定颜色,也可以使用十六进制值(前面带有井号字符) ( # ) ,格式为 #RRGGBB。You can specify a color either by name or by using a hexadecimal value, preceded by the pound character (#), in the form #RRGGBB. RR、GG 和 BB 表示0到255之间的十六进制值,分别指示颜色的红色、绿色和蓝色成分。RR, GG, and BB represent hexadecimal values from 0 to 255 that indicate the red, green, and blue components of a color, respectively. 例如,值 #0000FF 表示蓝色。For example, the value #0000FF represents the color blue. 它指定红色和绿色分量 (00) 的最小值,同时指定蓝色分量 (FF) 的最大值。It specifies the minimum value (00) for the red and green components, while specifying the maximum value (FF) for the blue component.
下表显示了十六种预定义的 HTML 颜色名称以及可用于属性的相应十六进制值 BorderColor 。The following table shows the sixteen predefined HTML color names and corresponding hexadecimal values that can be used for the BorderColor property. 有关 HTML 颜色的详细信息,请参阅 W3C) 网站 (万维网联合会 。For more information on HTML colors, see the World Wide Web Consortium (W3C) Web site.
| 颜色名称Color name | 十六进制值Hexadecimal value |
|---|---|
| AquaAqua | #00FFFF#00FFFF |
| 黑色Black | #000000#000000 |
| 蓝色Blue | #0000FF#0000FF |
| FuchsiaFuchsia | #FF00FF#FF00FF |
| 灰色Gray | #808080#808080 |
| 绿色Green | #008000#008000 |
| 酸Lime | #00FF00#00FF00 |
| 褐紫红色Maroon | #800000#800000 |
| NavyNavy | #000080#000080 |
| 橄榄绿Olive | #808000#808000 |
| 紫色Purple | #800080#800080 |
| RedRed | #FF0000#FF0000 |
| SilverSilver | #C0C0C0#C0C0C0 |
| 青色Teal | #008080#008080 |
| WhiteWhite | #FFFFFF#FFFFFF |
| YellowYellow | #FFFF00#FFFF00 |
BorderColor可从枚举确定用于属性的可用颜色 KnownColor 。The available colors for use with the BorderColor property can be determined from the KnownColor enumeration.
颜色名称不区分大小写。Color names are case-insensitive.