ListObject.DataBoundFormat (Propiedad) (2007 System)

Actualización: noviembre 2007

Obtiene o establece el estilo de formato para los controles ListObject enlazados a datos.

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

Sintaxis

Public Property DataBoundFormat As XlRangeAutoFormat

Dim instance As ListObject
Dim value As XlRangeAutoFormat

value = instance.DataBoundFormat

instance.DataBoundFormat = value
public XlRangeAutoFormat DataBoundFormat { get; set; }

Valor de propiedad

Tipo: Microsoft.Office.Interop.Excel.XlRangeAutoFormat

Uno de los valores de XlRangeAutoFormat.

Comentarios

El control ListObject se debe enlazar a los datos antes de poder utilizar esta propiedad.

El formato especificado se aplica al objeto de lista completo, incluidas las filas que se agregan después.

Para quitar el formato, establezca DataBoundFormat en xlRangeAutoFormatNone.

Utilice DataboundFormatSettings() para excluir tipos específicos de formato como modelo, fuente o ancho de estilo.

Ejemplos

El ejemplo de código siguiente crea DataTable y ListObject, y enlaza el control ListObject al control DataTable. Después utiliza un valor XlRangeAutoFormat para dar formato al ListObject.

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

Private Sub ListObject_DataBoundFormat()
    ' 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")

    ' Add a format to the list object.
    List1.DataBoundFormat = _
        Excel.XlRangeAutoFormat.xlRangeAutoFormatList2

End Sub

private void ListObject_DataBoundFormat()
{
    // 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");

    // Add a format to the list object.
    list1.DataBoundFormat = 
        Excel.XlRangeAutoFormat.xlRangeAutoFormatList2;
}

Permisos

Vea también

Referencia

ListObject (Clase)

ListObject (Miembros)

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