ListObject.DataBoundFormat (Propiedad)
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 (en Microsoft.Office.Tools.Excel.dll)
Sintaxis
'Declaración
Property DataBoundFormat As XlRangeAutoFormat
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"], "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;
}
Seguridad de .NET Framework
- Plena confianza para el llamador inmediato. Un código de confianza parcial no puede utilizar este miembro. Para obtener más información, vea Utilizar bibliotecas de código que no es de plena confianza.