Proprietà ListObject.TotalsRowRange (System 2007)

Aggiornamento: novembre 2007

Ottiene un oggetto Range che rappresenta la riga del totale del controllo ListObject.

Spazio dei nomi:  Microsoft.Office.Tools.Excel
Assembly:  Microsoft.Office.Tools.Excel.v9.0 (in Microsoft.Office.Tools.Excel.v9.0.dll)

Sintassi

<BrowsableAttribute(False)> _
Public ReadOnly Property TotalsRowRange As Range

Dim instance As ListObject
Dim value As Range

value = instance.TotalsRowRange
[BrowsableAttribute(false)]
public Range TotalsRowRange { get; }

Valore proprietà

Tipo: Microsoft.Office.Interop.Excel.Range

Oggetto Range che rappresenta la riga del totale del controllo ListObject.

Note

La proprietà restituisce Range unicamente se la riga del totale è visibile nel controllo ListObject. Se la riga del totale non è visibile, restituisce il valore nullriferimento null (Nothing in Visual Basic).

Esempi

Nell'esempio di codice riportato di seguito viene creato un oggetto DataTable e un controllo ListObject, quindi viene eseguita l'associazione tra il controllo ListObject e l'oggetto DataTable. Viene infine ottenuto l'intervallo che contiene la riga del totale e viene applicato lo stile corsivo al tipo di carattere della riga del totale.

Questo esempio è valido per una personalizzazione a livello di documento.

Private Sub ListObject_TotalsRowRange()
    ' Create a new DataSet and DataTable.
    Dim ds As New DataSet()
    Dim dt As DataTable = ds.Tables.Add("Sales")
    dt.Columns.Add(New DataColumn("Name"))
    dt.Columns.Add(New DataColumn("Quarter1"))

    ' Add a new row to the DataTable.
    Dim dr1 As DataRow = dt.NewRow()
    dr1("Name") = "Sidney"
    dr1("Quarter1") = "150"
    dt.Rows.Add(dr1)
    Dim dr2 As DataRow = dt.NewRow()
    dr2("Name") = "Julia"
    dr2("Quarter1") = "175"
    dt.Rows.Add(dr2)

    ' Create a list object.
    Dim List1 As Microsoft.Office.Tools.Excel.ListObject = _
        Me.Controls.AddListObject(Me.Range("A1"), "List1")

    ' Bind the list object to the DataTable.
    List1.AutoSetDataBoundColumnHeaders = True
    List1.SetDataBinding(ds, "Sales", "Name", "Quarter1")
    List1.ShowTotals = True

    ' Get the header row range and set the font to bold.
    Dim totalRow As Excel.Range = List1.TotalsRowRange
    totalRow.Cells.Font.Italic = True
End Sub

private void ListObject_TotalsRowRange()
{
    // Create a new DataSet and DataTable.
    DataSet ds = new DataSet();
    DataTable dt = ds.Tables.Add("Sales");
    dt.Columns.Add(new DataColumn("Name"));
    dt.Columns.Add(new DataColumn("Quarter1"));

    // Add a new row to the DataTable.
    DataRow dr1 = dt.NewRow();
    dr1["Name"] = "Sidney";
    dr1["Quarter1"] = "150";
    dt.Rows.Add(dr1);
    DataRow dr2 = dt.NewRow();
    dr2["Name"] = "Julia";
    dr2["Quarter1"] = "175";
    dt.Rows.Add(dr2);

    // Create a list object.
    Microsoft.Office.Tools.Excel.ListObject list1 =
        this.Controls.AddListObject(
        this.Range["A1", missing], "list1");

    // Bind the list object to the DataTable.
    list1.AutoSetDataBoundColumnHeaders = true;
    list1.SetDataBinding(ds, "Sales", "Name",
        "Quarter1");
    list1.ShowTotals = true;

    // Get the header row range and set the font to bold.
    Excel.Range totalRow = list1.TotalsRowRange;
    totalRow.Cells.Font.Italic = true;
}

Autorizzazioni

Vedere anche

Riferimenti

ListObject Classe

Membri ListObject

Spazio dei nomi Microsoft.Office.Tools.Excel