TableCellCollection.RemoveAt(Int32) Metoda
Definice
Důležité
Některé informace platí pro předběžně vydaný produkt, který se může zásadně změnit, než ho výrobce nebo autor vydá. Microsoft neposkytuje žádné záruky, výslovné ani předpokládané, týkající se zde uváděných informací.
Odebere ze zadaného indexu ze TableCell zadaného indexu TableCellCollection .
public:
virtual void RemoveAt(int index);
public void RemoveAt(int index);
abstract member RemoveAt : int -> unit
override this.RemoveAt : int -> unit
Public Sub RemoveAt (index As Integer)
Parametry
- index
- Int32
Index odebrání TableCell z objektu TableCellCollection.
Implementuje
Příklady
Následující příklad ukazuje použití RemoveAt metody k odebrání čtvrtého sloupce z tabulky. Všimněte si, Cells že v příkladu je vlastnost TableRow třídy instance TableCellCollection . Všimněte si také, že index Cells kolekce je založený na nule.
<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
void Page_Load(Object sender, EventArgs e)
{
int numRows = 5;
int numCells = 7;
int counter = 1;
// Create a table.
for (int rowNum = 0; rowNum < numRows; rowNum++)
{
TableRow rw = new TableRow();
for (int cellNum = 0; cellNum < numCells; cellNum++)
{
TableCell cel = new TableCell();
cel.Text = counter.ToString();
counter++;
rw.Cells.Add(cel);
}
Table1.Rows.Add(rw);
}
// Remove the center column.
for (int rowNum = 0; rowNum < numRows; rowNum++)
{
Table1.Rows[rowNum].Cells.RemoveAt(3);
}
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head2" runat="server">
<title>TableCellCollection Example</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h3>TableCellCollection Example</h3>
<asp:Table id="Table1" runat="server" />
</div>
</form>
</body>
</html>
<%@ Page Language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
Dim numRows As Integer = 5
Dim numCells As Integer = 7
Dim counter As Integer = 1
' Create a table.
Dim rowNum As Integer
For rowNum = 0 To numRows - 1
Dim rw As New TableRow()
Dim cellNum As Integer
For cellNum = 0 To numCells - 1
Dim cel As New TableCell()
cel.Text = counter.ToString()
counter += 1
rw.Cells.Add(cel)
Next cellNum
Table1.Rows.Add(rw)
Next rowNum
' Remove the center column.
For rowNum = 0 To numRows - 1
Table1.Rows(rowNum).Cells.RemoveAt(3)
Next rowNum
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>TableCellCollection Example</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h3>TableCellCollection Example</h3>
<asp:Table id="Table1" runat="server" />
</div>
</form>
</body>
</html>
Poznámky
Tuto metodu TableCell použijte k odebrání ze zadaného indexu TableCellCollection .