指定したインデックス位置にある HtmlTableRow オブジェクトを HtmlTableRowCollection コレクションから削除します。
名前空間: System.Web.UI.HtmlControls
アセンブリ: System.Web (system.web.dll 内)
構文
'宣言
Public Sub RemoveAt ( _
index As Integer _
)
'使用
Dim instance As HtmlTableRowCollection
Dim index As Integer
instance.RemoveAt(index)
public void RemoveAt (
int index
)
public:
void RemoveAt (
int index
)
public void RemoveAt (
int index
)
public function RemoveAt (
index : int
)
適用できません。
パラメータ
- index
HtmlTableRowCollection から削除する HtmlTableRow のインデックス。
例外
| 例外の種類 | 条件 |
|---|---|
指定したインデックスが、コレクションのインデックス値の範囲外にあります。 |
解説
このメソッドを使用して、指定したインデックス位置にある HtmlTableRow オブジェクトを HtmlTableRowCollection コレクションから削除します。インデックス番号は 0 から始まっています。したがって、コレクションの最初の項目のインデックス値は 0 です。
メモ : |
|---|
インデックス値の範囲外のインデックスを指定すると、例外が発生します。 |
使用例
RemoveAt メソッドを使用して、指定したインデックス位置にある項目を HtmlTableRowCollection コレクションから削除する方法を次のコード例に示します。この例では、HtmlTable コントロールの最初の行を削除します。
<%@ 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)
' Remove the first row from the table.
Table1.Rows.RemoveAt(0)
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>HtmlTableRowCollection Example</title>
</head>
<body>
<form id="form1" runat="server">
<h3>HtmlTableRowCollection 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>
<br /><br />
<input type="button"
value="Remove First Row from Table"
onserverclick="Button_Click"
runat="server"/>
</form>
</body>
</html>
<%@ 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)
{
// Remove the first row from the table.
Table1.Rows.RemoveAt(0);
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>HtmlTableRowCollection Example</title>
</head>
<body>
<form id="form1" runat="server">
<h3>HtmlTableRowCollection 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>
<br /><br />
<input type="button"
value="Remove First Row from Table"
onserverclick="Button_Click"
runat="server"/>
</form>
</body>
</html>
<%@ Page Language="JScript" 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">
function Button_Click(sender, e : EventArgs)
{
// Remove the first row from the table.
Table1.Rows.RemoveAt(0);
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>HtmlTableRowCollection Example</title>
</head>
<body>
<form id="form1" runat="server">
<h3>HtmlTableRowCollection 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>
<br /><br />
<input type="button"
value="Remove First Row from Table"
onserverclick="Button_Click"
runat="server"/>
</form>
</body>
</html>
プラットフォーム
Windows 98,Windows Server 2000 SP4,Windows CE,Windows Millennium Edition,Windows Mobile for Pocket PC,Windows Mobile for Smartphone,Windows Server 2003,Windows XP Media Center Edition,Windows XP Professional x64 Edition,Windows XP SP2,Windows XP Starter Edition
Microsoft .NET Framework 3.0 は Windows Vista,Microsoft Windows XP SP2,および Windows Server 2003 SP1 でサポートされています。
バージョン情報
.NET Framework
サポート対象 : 3.0,2.0,1.1,1.0
参照
関連項目
HtmlTableRowCollection クラス
HtmlTableRowCollection メンバ
System.Web.UI.HtmlControls 名前空間
Remove
HtmlTable.Rows プロパティ
HtmlTableRow
メモ :