DataGridViewRow.DataBoundItem Propiedad
Definición
Obtiene el objeto enlazado a datos que ha rellenado la fila.Gets the data-bound object that populated the row.
public:
property System::Object ^ DataBoundItem { System::Object ^ get(); };
[System.ComponentModel.Browsable(false)]
public object DataBoundItem { get; }
member this.DataBoundItem : obj
Public ReadOnly Property DataBoundItem As Object
Valor de propiedad
- Atributos
Ejemplos
En el ejemplo de código siguiente se muestra cómo utilizar la propiedad DataBoundItem para tener acceso a un objeto comercial enlazado a una fila.The following code example demonstrates how to use the DataBoundItem property to access a business object bound to a row. Este ejemplo de código forma parte de un ejemplo más grande proporcionado en How para: Obtener acceso a los objetos enlazados a Windows Forms filas DataGridView.This code example is part of a larger example provided in How to: Access Objects Bound to Windows Forms DataGridView Rows.
void invoiceButton_Click(object sender, EventArgs e)
{
foreach (DataGridViewRow row in this.dataGridView1.SelectedRows)
{
Customer cust = row.DataBoundItem as Customer;
if (cust != null)
{
cust.SendInvoice();
}
}
}
Private Sub InvoiceButton_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles InvoiceButton.Click
For Each row As DataGridViewRow In Me.DataGridView1.SelectedRows
Dim cust As Customer = TryCast(row.DataBoundItem, Customer)
If cust IsNot Nothing Then
cust.SendInvoice()
End If
Next
End Sub
Comentarios
El acceso a objetos enlazados a datos directamente a través de objetos Row es útil cuando no se tiene acceso directo al origen de datos que contiene los objetos.Accessing data-bound objects directly through row objects is useful when you do not have direct access to the data source containing the objects. También resulta útil si desea manipular objetos enlazados a filas seleccionadas o a filas pasadas como argumentos a los controladores de eventos.It is also convenient when you want to manipulate objects bound to selected rows or to rows passed as arguments to event handlers.