HtmlTableCell.Height 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得或設定由 HtmlTableCell 類別其執行個體所表示儲存格的高度 (以像素為單位)。
public:
property System::String ^ Height { System::String ^ get(); void set(System::String ^ value); };
public string Height { get; set; }
member this.Height : string with get, set
Public Property Height As String
屬性值
以 HtmlTableCell 的執行個體所表示儲存格的高度 (以像素為單位)。 預設值為 Empty,表示這個屬性未設定。
範例
下列程式碼範例示範如何使用 Height 屬性,以程式設計方式控制 控制項中 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].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>
備註
Height使用 屬性可指定以圖元為單位的高度 (,以圖元為單位,以類別實例 HtmlTableCell 表示的儲存格) 。 當您指定儲存格的高度時,相同資料列中的所有儲存格都會自動共用該高度。
注意
如果您指定的高度小於顯示儲存格的內容,則會忽略這個屬性。