HtmlTableCellCollection.RemoveAt メソッド
指定したインデックス位置の HtmlTableCell を HtmlTableCellCollection から削除します。
Public Sub RemoveAt( _
ByVal index As Integer _)
[C#]
public void RemoveAt(intindex);
[C++]
public: void RemoveAt(intindex);
[JScript]
public function RemoveAt(
index : int);
パラメータ
- index
HtmlTableCellCollection から削除する HtmlTableCell のインデックス。
例外
例外の種類 | 条件 |
---|---|
ArgumentOutOfRangeException | 指定したインデックスが、コレクションのインデックス値の範囲外にあります。 |
解説
このメソッドを使用して、指定したインデックス位置の HtmlTableCell を HtmlTableCellCollection から削除します。インデックス番号が 0 から始まるため、コレクションの最初の項目のインデックス値は 0 です。
メモ インデックス値の範囲外のインデックスを指定すると、例外が発生します。
使用例
[Visual Basic, C#, JScript] RemoveAt メソッドを使用して、 HtmlTableCellCollection から指定したインデックス位置の項目を削除する方法の例を次に示します。この例では HtmlTable コントロールの最初の列からセルを削除します。
<%@ Page Language="VB" AutoEventWireup="True" %>
<html>
<head>
<script runat="server">
Sub Button_Click(sender As Object, e As EventArgs)
Dim i As Integer
' Iterate through the rows of the table.
For i=0 To Table1.Rows.Count - 1
' Remove the cells from the first column.
Table1.Rows(i).Cells.RemoveAt(0)
Next i
End Sub
</script>
</head>
<body>
<form runat="server">
<h3>HtmlTableCellCollection 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>
<br><br>
<input type="button"
value="Remove First Column from 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++)
{
// Remove the cells from the first column.
Table1.Rows[i].Cells.RemoveAt(0);
}
}
</script>
</head>
<body>
<form runat="server">
<h3>HtmlTableCellCollection 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>
<br><br>
<input type="button"
value="Remove First Column from Table"
OnServerClick = "Button_Click"
runat="server"/>
</form>
</body>
</html>
[JScript]
<%@ Page Language="JScript" AutoEventWireup="True" %>
<html>
<head>
<script runat="server">
function Button_Click(sender, e : EventArgs)
{
// Iterate through the rows of the table.
for (var i : int =0; i<=Table1.Rows.Count - 1; i++)
{
// Remove the cells from the first column.
Table1.Rows[i].Cells.RemoveAt(0);
}
}
</script>
</head>
<body>
<form runat="server">
<h3>HtmlTableCellCollection 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>
<br><br>
<input type="button"
value="Remove First Column from Table"
OnServerClick = "Button_Click"
runat="server"/>
</form>
</body>
</html>
[C++] C++ のサンプルはありません。Visual Basic、C#、および JScript のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン をクリックします。
必要条件
プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ
参照
HtmlTableCellCollection クラス | HtmlTableCellCollection メンバ | System.Web.UI.HtmlControls 名前空間 | Remove | Cells | HtmlTableRow