1

如何选择网格(gridCustomer)中的每一行,第二个网格(gridOrder)按我的顺序显示对象信息?

我将选择网格 (gridCustomer) 的第一行,但网格 (gridOrder) 不会显示任何内容。

项目文件

视频

    private void gridCustomer_CellContentClick(object sender, DataGridViewCellEventArgs e)
    {
        //var s = gridCustomer.Rows[e.RowIndex].Cells[e.ColumnIndex].Value;
        if (e.RowIndex >= 0)
        {
            DataGridViewRow row = this.gridCustomer.Rows[e.RowIndex];
            var selectedItme = row.Cells["Id"].Value;
            var objOrder = orderBusiness.OrderFindById(Convert.ToInt32(selectedItme));

            gridOrder.DataSource = objOrder;
        }
    }
4

1 回答 1

1
 private void gridCustomer_CellClick(object sender, DataGridViewCellEventArgs e)
    {
        if(e.RowIndex >= 0)
        {
            DataGridViewRow row = this.gridCustomer.Rows[e.RowIndex];
            var selectedItme = row.Cells["Id"].Value;
            var objOrder = orderBusiness.OrderFindById(Convert.ToInt32(selectedItme));

            /* Add This */
            BindingList<Order> bl = new BindingList<Order> { objOrder };                

            gridOrder.DataSource = bl;

        }
    }
于 2013-11-13T17:13:27.943 回答