DataGridViewRow.DataBoundItem 속성

정의

행을 채운 데이터 바인딩된 개체를 가져옵니다.

public:
 property System::Object ^ DataBoundItem { System::Object ^ get(); };
[System.ComponentModel.Browsable(false)]
public object DataBoundItem { get; }
[<System.ComponentModel.Browsable(false)>]
member this.DataBoundItem : obj
Public ReadOnly Property DataBoundItem As Object

속성 값

Object

데이터 바인딩된 Object입니다.

특성

예제

다음 코드 예제에서는 행에 바인딩된 비즈니스 개체에 DataBoundItem 액세스 하는 속성을 사용 하는 방법을 보여 줍니다. 이 코드 예제는 방법: DataGridView 행을 Windows Forms 바인딩된 액세스 개체에 제공된 더 큰 예제의 일부입니다.

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

설명

행 개체를 통해 직접 데이터 바인딩된 개체에 액세스하는 것은 개체가 포함된 데이터 원본에 직접 액세스할 수 없는 경우에 유용합니다. 또한 선택한 행 또는 이벤트 처리기에 인수로 전달된 행에 바인딩된 개체를 조작하려는 경우에도 편리합니다.

적용 대상

추가 정보