Index: Ringtoets/Common/src/Ringtoets.Common.Forms/Views/FailureMechanismResultView.cs =================================================================== diff -u -rbe3779b7be55ce7821035393e89cdde997b15883 -rce8424c77c708edc0bb2150a9a6a0e75dad629fa --- Ringtoets/Common/src/Ringtoets.Common.Forms/Views/FailureMechanismResultView.cs (.../FailureMechanismResultView.cs) (revision be3779b7be55ce7821035393e89cdde997b15883) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/Views/FailureMechanismResultView.cs (.../FailureMechanismResultView.cs) (revision ce8424c77c708edc0bb2150a9a6a0e75dad629fa) @@ -19,6 +19,7 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System; using System.Collections.Generic; using System.Linq; using System.Windows.Forms; @@ -44,12 +45,20 @@ private IFailureMechanism failureMechanism; /// + /// Creates a display object for which is added to the + /// on the . + /// + /// The for which to create a + /// display object. + /// A display object which can be added as a row to the . + protected abstract object CreateFailureMechanismSectionResultRow(T sectionResult); + + /// /// Creates a new instance of . /// protected FailureMechanismResultView() { InitializeComponent(); - InitializeDataGridView(); failureMechanismObserver = new Observer(UpdataDataGridViewDataSource); failureMechanismSectionResultObservers = new List(); @@ -118,17 +127,11 @@ } /// - /// Gets all the columns that should be added to the on the - /// . - /// - /// An of . - protected abstract void AddDataGridColumns(); - - /// /// Updates the data source of the data grid view with the current known failure mechanism section results. /// protected void UpdataDataGridViewDataSource() { + UpdateFailureMechanismSectionResultsObservers(); DataGridViewControl.EndEdit(); DataGridViewControl.SetDataSource(failureMechanismSectionResult.Select(CreateFailureMechanismSectionResultRow).ToList()); } @@ -143,29 +146,25 @@ return DataGridViewControl.GetRowFromIndex(rowIndex).DataBoundItem; } - /// - /// Creates a display object for which is added to the - /// on the . - /// - /// The for which to create a - /// display object. - /// A display object which can be added as a row to the . - protected abstract object CreateFailureMechanismSectionResultRow(T sectionResult); - private IEnumerable FailureMechanismSectionResult { set { - ClearSectionResultObservers(); failureMechanismSectionResult = value; - if (failureMechanismSectionResult != null) - { - AddSectionResultObservers(); - } + UpdateFailureMechanismSectionResultsObservers(); } } + private void UpdateFailureMechanismSectionResultsObservers() + { + ClearSectionResultObservers(); + if (failureMechanismSectionResult != null) + { + AddSectionResultObservers(); + } + } + private void AddSectionResultObservers() { foreach (var sectionResult in failureMechanismSectionResult) @@ -185,10 +184,5 @@ } failureMechanismSectionResultObservers.Clear(); } - - private void InitializeDataGridView() - { - AddDataGridColumns(); - } } } \ No newline at end of file