private void ContactsGrid_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex > 0 && e.RowIndex < contactDataGridView.Rows.Count) { DataGridViewRow row = contactDataGridView.Rows[e.RowIndex]; Contact selectedContact = row.DataBoundItem as Contact; if (selectedContact != null) { ContactEditDialog dialog = new ContactEditDialog( new EditableContact(selectedContact)); dialog.ShowDialog(); } } }