private void dataGridView1_SelectionChanged(object sender, EventArgs e) { if (!(this.isClosing || this.selectingRecords) && activated) { shapeFileReference.ClearSelectedRecords(); int colIndex = dataTable.Columns.IndexOf(ShapeFileRecordIndexColumnName); foreach (DataGridViewRow row in this.dataGridView1.SelectedRows) { shapeFileReference.SelectRecord((int)row.Cells[colIndex].Value, true); } if (mapReference != null) { mapReference.InvalidateAndClearBackground(); } this.tslblRecords.Text = string.Format("{0} records of {1} selected", dataGridView1.SelectedRows.Count, dataGridView1.Rows.Count); } }