Im trying to create a program that select row 1 at a time and print specific column in messagebox but the output was only the first item and will be repeated based on how many rows in my datagridview. Anyone knows what im missing? Thanks in advance
dgvCart was my datagridview
private void button1_Click_2(object sender, EventArgs e)
{ for (int i = 0 ; i < dgvCart.Rows.Count; i++) { dgvCart.ClearSelection(); dgvCart.Rows[i].Selected = true; if (dgvCart.SelectedCells.Count > 0) { int selectedrowindex = dgvCart.SelectedCells[i].RowIndex; DataGridViewRow selectedRow = dgvCart.Rows[selectedrowindex]; string _name = Convert.ToString(selectedRow.Cells["Column1"].Value); decimal _quantity = Convert.ToDecimal(selectedRow.Cells["Column3"].Value); MessageBox.Show("NAME: " + "Quantity: " + _quantity.ToString()); dgvCart.Rows[i].Selected = false; } // string _name = dgvCart.CurrentRow.Cells[0].Value.ToString(); // decimal _quantity = Convert.ToDecimal(dgvCart.CurrentRow.Cells[2].Value.ToString()); } }