C# WinForm编程之System.Windows.Forms.DataGridViewRow.DataBoundItem Property

Namespace:

System.Windows.Forms

Assembly:

System.Windows.Forms.dll

获取用于填充行的数据绑定对象。

下面的代码示例演示如何使用 DataBoundItem 属性访问绑定到行的业务对象。 此代码示例是如何:访问绑定到 Windows 窗体 DataGridView 行的对象中提供的一个更大示例的一部分。

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();
        }
    }
}

Remarks

当你不能直接访问包含对象的数据源时,通过行对象直接访问数据绑定对象非常有用。 当您希望操作绑定到选定行或作为参数传递给事件处理程序的行时,这也是非常方便的。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值