private void dgv_CellEndEdit(object sender, DataGridViewCellEventArgs e)
{
int MaxRows = dgv.Rows.Count;
for (int i = 0; i < MaxRows-1; i++)
{
SqlDataAdapter da = new SqlDataAdapter("SELECT CAST(originalPrice * " + (1.00 + (float.Parse(txtMarkUp.Text) / 100.00)).ToString() + " * " + (1.00 + (float.Parse(dgv.Rows[i].Cells[4].Value.ToString()) / 100.00)).ToString() + " AS decimal (8,2)) AS sellingPrice FROM Warehouse WHERE barcode = '" + Convert.ToString(dgv.Rows[i].Cells[2].Value) + "'", conn);
DataTable dt = new DataTable();
da.Fill(dt);
DataGridViewComboBoxColumn sellingPrice = dgv.Columns["sellingPrice"] as DataGridViewComboBoxColumn;
sellingPrice.DataSource = dt;
sellingPrice.ValueMember = "sellingPrice";
sellingPrice.DisplayMember = "sellingPrice";
dgv.Rows[i].Cells[5].Value = dt.Rows[0].ItemArray.GetValue(0);
dgv.Rows[i].Cells[4].Value = dt.Rows[0].ItemArray.GetValue(2).ToString();
}
}
This code works fine, but only for one value in combobox ... I need different values on different lines for combobox. How can i do this? In the example, when the product is changed in column 2, I need to change the value of column 5, which is a discount list. Any help would be appreciated, I have almost no solution for this in my mind. Thank.
source
share