ListObject.SourceType (Propiedad)

Obtiene el origen actual de la lista.

Espacio de nombres:  Microsoft.Office.Tools.Excel
Ensamblado:  Microsoft.Office.Tools.Excel (en Microsoft.Office.Tools.Excel.dll)

Sintaxis

'Declaración
ReadOnly Property SourceType As XlListObjectSourceType
    Get
XlListObjectSourceType SourceType { get; }

Valor de propiedad

Tipo: Microsoft.Office.Interop.Excel.XlListObjectSourceType
Uno de los valores de XlListObjectSourceType.

Ejemplos

En el ejemplo de código siguiente se crea DataTable y ListObject, y se enlaza el control ListObject al control DataTable. Después muestra el origen de la lista en un mensaje.

Se trata de un ejemplo para una personalización en el nivel del documento.

    Private Sub ListObject_SourceType()
        ' Create a new DataSet and DataTable.
        Dim ds As New DataSet()
        Dim dt As DataTable = ds.Tables.Add("Customers")
        dt.Columns.Add(New DataColumn("LastName"))
        dt.Columns.Add(New DataColumn("FirstName"))

        ' Add a new row to the DataTable.
        Dim dr As DataRow = dt.NewRow()
        dr("LastName") = "Chan"
        dr("FirstName") = "Gareth"
        dt.Rows.Add(dr)

        ' 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, "Customers", _
            "LastName", "FirstName")

        ' Get the source type and display it in a message.
        MessageBox.Show("The source type of List1 is " & _
            List1.SourceType.ToString() & ".")
    End Sub

private void ListObject_SourceType()
{
    // Create a new DataSet and DataTable.
    DataSet ds = new DataSet();
    DataTable dt = ds.Tables.Add("Customers");
    dt.Columns.Add(new DataColumn("LastName"));
    dt.Columns.Add(new DataColumn("FirstName"));

    // Add a new row to the DataTable.
    DataRow dr = dt.NewRow();
    dr["LastName"] = "Chan";
    dr["FirstName"] = "Gareth";
    dt.Rows.Add(dr);

    // 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, "Customers", "LastName",
        "FirstName");

    // Get the source type and display it in a message.
    MessageBox.Show("The source type of list1 is " +
        list1.SourceType.ToString() + ".");
}

Seguridad de .NET Framework

Vea también

Referencia

ListObject Interfaz

Microsoft.Office.Tools.Excel (Espacio de nombres)