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(); //percent of tax for that category of product
}
}
이 코드는 완벽하게 작동하지만 콤보 상자의 한 값만 ...이 콤보 상자의 다른 행에는 다른 값이 필요합니다. 어떻게해야합니까? 예를 들어 2 열 제품이 변경된 경우 5 열의 값을 판매 가격과 함께 변경해야합니다. 도움이된다면, 제 마음에는 거의 해결책이 없습니다. 감사.다른 행에있는 DataGridView의 다른 ComboBox 값
네, 그게 내가 원하는거야. 그리고 내가 잘못 쓴 것이 .. 나에게 방향을 알려준 것에 대해 고마워. p.s. 이것은 datamember와 valuemember가 설정되지 않았기 때문에 여전히 나에게 오류를주고있다. 어떻게 내가 그 세포에 그들을 설정할 수 있습니까? – dex
DataGridViewComboBoxCell 값이 유효하지 않다고합니다. – dex
회원 설정을 위해 편집 됨. – V4Vendetta