HtmlTableCell.BgColor Özellik
Tanım
Önemli
Bazı bilgiler ürünün ön sürümüyle ilgilidir ve sürüm öncesinde önemli değişiklikler yapılmış olabilir. Burada verilen bilgilerle ilgili olarak Microsoft açık veya zımni hiçbir garanti vermez.
Sınıfın bir örneği HtmlTableCell tarafından temsil edilen hücrenin arka plan rengini alır veya ayarlar.
public:
property System::String ^ BgColor { System::String ^ get(); void set(System::String ^ value); };
public string BgColor { get; set; }
member this.BgColor : string with get, set
Public Property BgColor As String
Özellik Değeri
bir örneğiyle HtmlTableCelltemsil edilen hücrenin arka plan rengi.
Örnekler
Aşağıdaki kod örneği, bir HtmlTable denetimdeki BgColor hücrelerin arka plan rengini program aracılığıyla denetlemek için özelliğinin nasıl kullanılacağını gösterir.
<%@ 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>
Açıklamalar
BgColor sınıfının bir örneği HtmlTableCell tarafından temsil edilen hücrenin arka plan rengini belirtmek için özelliğini kullanın. #RRGGBB formda, adıyla veya önünde pound karakteri (#) bulunan onaltılık bir değer kullanarak bir renk belirtebilirsiniz. RR, GG ve BB, sırasıyla bir rengin kırmızı, yeşil ve mavi bileşenlerini gösteren 0 ile 255 arasındaki onaltılık değerleri temsil eder. Örneğin, #0000FF değeri mavi rengi temsil eder. Mavi bileşen için en yüksek değeri (FF) belirtirken kırmızı ve yeşil bileşenler için en düşük değeri (00) belirtir.
Aşağıdaki tabloda, önceden tanımlanmış on altı HTML renk adı ve özellik için BgColor kullanılabilecek karşılık gelen onaltılık değerler gösterilmektedir. HTML renkleri hakkında daha fazla bilgi için World Wide Web Consortium (W3C) Web sitesine bakın.
| Renk adı | Onaltılık değer |
|---|---|
| Aqua | #00FFFF |
| Black | #000000 |
| Mavi | #0000FF |
| Fuşya | #FF00FF |
| Gray | #808080 |
| Green | #008000 |
| Kireç | #00FF00 |
| Bordo | #800000 |
| Donanma | #000080 |
| Zeytin | #808000 |
| Purple | #800080 |
| Red | #FF0000 |
| Gümüş | #C0C0C0 |
| Çamurcun | #008080 |
| White | #FFFFFF |
| Yellow | #FFFF00 |
özelliğiyle BgColor kullanılacak kullanılabilir renkler numaralandırmadan KnownColor belirlenebilir.
Renk adları büyük/küçük harfe duyarlı değildir.