다음을 통해 공유


TableRowCollection.Remove(TableRow) 메서드

정의

TableRow에서 지정된 TableRowCollection을 제거합니다.

public:
 void Remove(System::Web::UI::WebControls::TableRow ^ row);
public void Remove (System.Web.UI.WebControls.TableRow row);
member this.Remove : System.Web.UI.WebControls.TableRow -> unit
Public Sub Remove (row As TableRow)

매개 변수

row
TableRow

TableRow에서 제거할 TableRowCollection 개체입니다.

예제

다음 예제에서는 사용 하는 Remove 방법에 설명 합니다 테이블에서 행을 제거 하는 방법입니다. 예제에서 의 RowsTable 속성은 클래스의 TableRowCollection 인스턴스입니다.

<%@ 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)
    {
        // Generate rows and cells.           
        int numRows = 5;
        int numCells = 6;
    int counter = 1;

        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();
                rw.Cells.Add(cel);
                counter++;
            }
            Table1.Rows.Add(rw);
            Table1.GridLines = GridLines.Both;
            Table1.CellPadding = 4;
            Table1.CellSpacing = 0;
        }
    }

    void Button_Click(object sender, EventArgs e)
    {
        TableRow rw = Table1.Rows[2];
        Table1.Rows.Remove(rw);
    }
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title>TableCellCollection Example</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <h3>TableCellCollection Example</h3>
        <asp:Table id="Table1" runat="server"/>
        <br /> <br />
        <asp:Button id="Button1"
            Text="Remove middle row"
            OnClick="Button_Click"
            runat="server"/>
    </div>
    </form>
</body>
</html>
<%@ Page Language="VB" %>
<%@ Import Namespace="System.Text" %>

<!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 = 6
        Dim counter As Integer = 1
        Dim a_row As New ArrayList()
            
        ' 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()
                rw.Cells.Add(cel)
                counter += 1
            Next
            Table1.Rows.Add(rw)
        Next
    End Sub

    Sub Button_Click(ByVal sender As Object, ByVal e As EventArgs)
        Dim rw As TableRow = Table1.Rows(2)
        Table1.Rows.Remove(rw)
    End Sub
</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"/>
        <br /> <br />
        <asp:Button id="Button1"
            Text="Remove middle row"
            OnClick="Button_Click"
            runat="server"/>
    </div>
    </form>
</body>
</html>

설명

이 메서드를 사용하여 에서 지정된 TableRow 을 제거합니다 TableRowCollection.

적용 대상

추가 정보