jeudi 21 mars 2019

checkbox inside datagridview value

i want to check where checkbox is checked or not inside "dataGridView1". baseon the value of checkedbox i want to calculate rtn & amt.

int rtn = 0;
                int amt=0;
                if (str == "GRI")
                {                
                    for (int n = 0; n <= dataGridView1.RowCount - 1; n++)
                    {
                        rtn = 0;
                        amt = 0;
                        bool chk =(bool)dataGridView1.Rows[n].Cells[4].Value;
                        if (chk)
                        {
                            dataGridView1.Rows[n].Cells[2].ReadOnly = false;
                            rtn +=Convert.ToInt32(dataGridView1.Rows[n].Cells[2].Value);
                            amt += Convert.ToInt32(dataGridView1.Rows[n].Cells[2].Value) * Convert.ToInt32(dataGridView1.Rows[n].Cells[3].Value);
                        }
                        else
                        {

                        }
                    }
                }
                totpcslbl.Text = rtn.ToString();
                totamtrtnlbl.Text = amt.ToString();




Aucun commentaire:

Enregistrer un commentaire