HtmlTableCellCollection.Remove(HtmlTableCell) 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
从 HtmlTableCell 集合中移除指定的 HtmlTableCellCollection 对象。
public:
void Remove(System::Web::UI::HtmlControls::HtmlTableCell ^ cell);
public void Remove (System.Web.UI.HtmlControls.HtmlTableCell cell);
member this.Remove : System.Web.UI.HtmlControls.HtmlTableCell -> unit
Public Sub Remove (cell As HtmlTableCell)
参数
- cell
- HtmlTableCell
要从 HtmlTableCell 移除的 HtmlTableCellCollection。
示例
下面的代码示例演示如何使用Remove该方法从集合中删除由对象HtmlTableCellCollection表示HtmlTableCell的表的指定单元格。 本示例从控件的第一列中 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++)
{
// Remove the cells from the first column.
HtmlTableCell cell = Table1.Rows[i].Cells[0];
Table1.Rows[i].Cells.Remove(cell);
}
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>HtmlTableCellCollection Example</title>
</head>
<body>
<form id="form1" runat="server">
<h3>HtmlTableCellCollection Example</h3>
<table id="Table1"
style="border-width:1; border-color:Black"
runat="server">
<tr>
<td>
Cell 1
</td>
<td>
Cell 2
</td>
</tr>
<tr>
<td>
Cell 3
</td>
<td>
Cell 4
</td>
</tr>
</table>
<br /><br />
<input type="button"
value="Remove First Column from 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 cell As HtmlTableCell
' Iterate through the rows of the table.
For i = 0 To Table1.Rows.Count - 1
' Remove the cells from the first column.
cell = Table1.Rows(i).Cells(0)
Table1.Rows(i).Cells.Remove(cell)
Next i
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>HtmlTableCellCollection Example</title>
</head>
<body>
<form id="form1" runat="server">
<h3>HtmlTableCellCollection Example</h3>
<table id="Table1"
style="border-width:1; border-color:Black"
runat="server">
<tr>
<td>
Cell 1
</td>
<td>
Cell 2
</td>
</tr>
<tr>
<td>
Cell 3
</td>
<td>
Cell 4
</td>
</tr>
</table>
<br /><br />
<input type="button"
value="Remove First Column from Table"
onserverclick="Button_Click"
runat="server"/>
</form>
</body>
</html>
注解
使用此方法从集合中删除指定的 HtmlTableCell 对象 HtmlTableCellCollection 。
备注
如果指定 HtmlTableCell 集合中 HtmlTableCellCollection 不存在的对象,则不会从集合中删除任何项。