private void datagridview1_SelectionChanged(object sender, EventArgs e) { for (int i = 0; i < datagridview1.SelectedCells.Count; i++) { if (!datagridview1.SelectedCells.Contains(datagridview1.Rows[i].Cells[i])) { float nextNumber = 0; float sumNumbers = 0; if (float.TryParse(datagridview1.SelectedCells[i].FormattedValue.ToString(), out nextNumber)) sumNumbers += nextNumber; label13.Text = "selected value: " + sumNumbers; label16.Text = "Nr.selected cell: " + datagridview1.SelectedCells.Count.ToString(); } else { MessageBox.Show("Can't sum"); } }
float sumNumbers = 0;
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)