private void DeleteItem(EventArgs e) { if (grdLabelFormats.SelectedRows.Count == 0) { return; } var selectedRow = (grdLabelFormats.SelectedRows[0].DataBoundItem as LabelFormat); try { _configService.DeleteLabelFormat(selectedRow.Id); LoadData(); } catch (Exception exception) { string message = $"There was an issue deleting the record from the database.{Environment.NewLine} {Environment.NewLine}{exception.Message}"; MessageBox.Show(message, "Label Formats", MessageBoxButtons.OK, MessageBoxIcon.Error); } }