Condividi tramite


ListObject.ListRows Property

Definition

Gets a ListRows object that represents all the rows of data in the ListObject control.

public:
 property Microsoft::Office::Interop::Excel::ListRows ^ ListRows { Microsoft::Office::Interop::Excel::ListRows ^ get(); };
public Microsoft.Office.Interop.Excel.ListRows ListRows { get; }
member this.ListRows : Microsoft.Office.Interop.Excel.ListRows
Public ReadOnly Property ListRows As ListRows

Property Value

A ListRows object that represents all the rows of data in the ListObject control.

Examples

The following code example creates a ListObject, gets the collection of rows, and then displays a message showing how many rows the ListObject contains.

This example is for a document-level customization.

private void ListObject_ListRows()
{
    Microsoft.Office.Tools.Excel.ListObject list1 =
        this.Controls.AddListObject(
        this.Range["A1", "C4"], "list1");

    Excel.ListRows list1Rows = list1.ListRows;
    MessageBox.Show("The list object contains " +
        list1Rows.Count.ToString() + " rows.");
}
Private Sub ListObject_ListRows()
    Dim List1 As Microsoft.Office.Tools.Excel.ListObject = _
        Me.Controls.AddListObject(Me.Range("A1", "C4"), "List1")

    Dim List1Rows As Excel.ListRows = List1.ListRows
    MessageBox.Show("The list object contains " & _
        List1Rows.Count.ToString() & " rows.")
End Sub

Remarks

The ListRows object returned does not include the header, Total, or Insert rows.

To delete any items from this collection, do not use the Delete method of the item. Use the Delete method of the range of the item to delete the item; for example ListRows.Item(1).Range.Delete().

Applies to