private void SceneExplorerOnClosed(object sender, EventArgs e) { List <IILayer> selectedLayers = layerSelector.SelectedLayers; if (selectedLayers.Count > 0) { int highestRowIndexEdited = layersRowIndex; var selectedRow = ExportItemGridView.Rows[layersRowIndex]; ExportItem existingItem = selectedRow.Tag as ExportItem; if (existingItem == null) { existingItem = TryAddExportItem(selectedRow, selectedLayers); } else { existingItem.SetExportLayers(selectedLayers); } // may be null after trying to add a node that already exists in another row if (existingItem != null) { SetRowData(selectedRow, existingItem); } // have to explicitly set it dirty for an edge case: // when a new row is added "automatically-programmatically", through notify cell dirty and endedit(), // if the user then clicks on the checkbox of the newly added row, // it doesn't add a new row "automatically", whereas otherwise it will. ExportItemGridView.CurrentCell = ExportItemGridView[layersColumnIndex, highestRowIndexEdited]; ExportItemGridView.NotifyCurrentCellDirty(true); ExportItemGridView.EndEdit(); } }