I am trying to create a dataGridView which has 2 columns, column 1 contains names, and column 2 contains numbers, which is working fine.
I now want to allow the user to select a single or multiple rows using the keyboard or mouse which should automatically total up the numbers column based on the rows selected.
I so far have the following:
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
if (dataGridView1.SelectedCells.Count > 0)
{
int selectedrowindex = dataGridView1.SelectedCells[0].RowIndex;
DataGridViewRow selectedRow = dataGridView1.Rows[selectedrowindex];
string a = Convert.ToString(selectedRow.Cells[0].Value);
}
}
Where string a will eventually show the total in a label on the form.
But this seems to be the wrong way to go about doing what I am trying to achieve. Any suggestions?