private void grdIncidents_CellClick(object sender, DataGridViewCellEventArgs e) { // Ignore clicks that are not on button cells. if (e.RowIndex < 0 || e.ColumnIndex != grdIncidents.Columns[_viewMapColumnName].Index) { return; } try { ActiveIncidentRecord incident = (ActiveIncidentRecord)grdIncidents.Rows[e.RowIndex].DataBoundItem; LaunchGoogleMaps(incident.Latitude, incident.Longitude); } catch (Exception ex) { MessageBox.Show(ex.ToString(), "Error: " + ex.Message); } }
private void googleMapsToolStripMenuItem_Click(object sender, EventArgs e) { if (grdIncidents.SelectedCells.Count == 0) { return; } DataGridViewCell selectedCell = grdIncidents.SelectedCells[0]; DataGridViewRow selectedRow = selectedCell.OwningRow; try { ActiveIncidentRecord incident = (ActiveIncidentRecord)selectedRow.DataBoundItem; LaunchGoogleMaps(incident.Latitude, incident.Longitude); } catch (Exception ex) { MessageBox.Show(ex.ToString(), "Error: " + ex.Message); } }