I have two DatagridViews in Windowsform c#, in one I have selected all my products(Dgtv_artikelbestellung) from Database and dipslayed there.
the other one is for ordered product (dgv_bestellteArtikel, I want if I click one the sign "+" it adds that selected row to the other DataGridView and if I double click on the same selected row it should then in the 2nd Datagridview ++1 in columns "Menge"Quantity. So far I can add the rows but that if I second time add the same product it doesn't add quantity. How can I achive that? Can someome please help? here how it looks like: Datagridview demo And here the code I have for it.
private void Dgtv_artikelbestellung_CellClick(object sender, DataGridViewCellEventArgs e)
{
string tttts = "";
bool gefunden = false;
if (Dgtv_artikelbestellung.Rows.Count > 0 && Dgtv_artikelbestellung.SelectedRows.Count > 0)
{
for (int i = 0; i < Dgtv_artikelbestellung.SelectedRows.Count; i++)
{
int indexvar = dgv_bestellteArtikel.Rows.Add();
dgv_bestellteArtikel.Rows[indexvar].Cells[0].Value = Dgtv_artikelbestellung.SelectedRows[i].Cells[0].Value.ToString();
dgv_bestellteArtikel.Rows[indexvar].Cells[1].Value = Dgtv_artikelbestellung.SelectedRows[i].Cells[1].Value.ToString();
dgv_bestellteArtikel.Rows[indexvar].Cells["Menge"].Value = Convert.ToInt32(dgv_bestellteArtikel.Rows[indexvar].Cells["Menge"].Value) + 1;
tttts=dgv_bestellteArtikel.Rows[indexvar].Cells["Menge"].Value.ToString();
if(tttts != null && tttts.ToString()== tttts)
{
gefunden = true;
}
}
}
It looks like the cell's value is changed but DatagridView control is not updated. Try to call EndInit() method.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.