DataGridViewTextBoxCell值与DataGridViewComboBoxCell所选值相乘,并将其分配给DataGridViewTextBoxCell C#

时间:2018-08-05 18:47:10

标签: c# data-binding datagridviewcomboboxcell datagridviewtextboxcell

UI
{   私有无效btnAddItem_Click(对象发送者,EventArgs e)         {             DataTable Dt = DB.SelectItemDetails(Convert.ToString(txtItemList.Text));

        DataGridViewRow row = new DataGridViewRow();
        row.Cells.Add(new DataGridViewTextBoxCell { Value = Dt.Rows[0]["ItemName"] });
        row.Cells.Add(new DataGridViewTextBoxCell { Value = Dt.Rows[0]["ItemPrice"] });
        int num = Convert.ToInt16(Dt.Rows[0]["Qty"]);
        int[] numArry = new int[num];
        for (int i =0 ; i < num; i++)
        {
            numArry[i] = i+1;
        }

        row.Cells.Add(new DataGridViewComboBoxCell { DataSource = numArry , Value = numArry[0] });


        row.Cells.Add(new DataGridViewTextBoxCell { Value = "" });
        row.Cells.Add(new DataGridViewButtonCell { Value = "Remove"});
        dgvBill.Rows.Add(row);

        txtItemList.Text = "";

    }

需要根据datagridviewcomboboxCell选择的值和datagridview组合框文本框单元格值进行计算,并将其分配给同一行中的datagridview文本框单元格。我是该领域的新学生,对如何执行此操作没有正确的认识。喜欢学习有关此数据绑定的最佳做法

0 个答案:

没有答案