Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultViews/MacroStabilityOutwardsResultView.cs =================================================================== diff -u -r26ee4ff0515942af0d34790c13a16ac78f67e891 -r0fff5b5ee6fee520f8bb86793e7d70cab6069766 --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultViews/MacroStabilityOutwardsResultView.cs (.../MacroStabilityOutwardsResultView.cs) (revision 26ee4ff0515942af0d34790c13a16ac78f67e891) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultViews/MacroStabilityOutwardsResultView.cs (.../MacroStabilityOutwardsResultView.cs) (revision 0fff5b5ee6fee520f8bb86793e7d70cab6069766) @@ -20,9 +20,10 @@ // All rights reserved. using System; +using System.Collections.Generic; using System.Linq; -using System.Windows.Forms; using Core.Common.Base; +using Core.Common.Controls.DataGrid; using Core.Common.Util; using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.Common.Forms.Helpers; @@ -59,20 +60,17 @@ } this.assessmentSection = assessmentSection; + + FormattingRules = CreateFormattingRules(); } + protected override IEnumerable> FormattingRules { get; } + protected override MacroStabilityOutwardsSectionResultRow CreateFailureMechanismSectionResultRow(MacroStabilityOutwardsFailureMechanismSectionResult sectionResult) { return new MacroStabilityOutwardsSectionResultRow(sectionResult); } - protected override void Dispose(bool disposing) - { - DataGridViewControl.CellFormatting -= OnCellFormatting; - - base.Dispose(disposing); - } - protected override void AddDataGridColumns() { DataGridViewControl.AddTextBoxColumn( @@ -101,27 +99,23 @@ RingtoetsCommonFormsResources.FailureMechanismResultView_TailorMadeAssessment_DisplayName); } - protected override void BindEvents() + private IEnumerable> CreateFormattingRules() { - base.BindEvents(); - - DataGridViewControl.CellFormatting += OnCellFormatting; - } - - private void OnCellFormatting(object sender, DataGridViewCellFormattingEventArgs eventArgs) - { - if (eventArgs.ColumnIndex > SimpleAssessmentColumnIndex) + return new[] { - SimpleAssessmentResultType simpleAssessmentResult = GetDataAtRow(eventArgs.RowIndex).SimpleAssessmentResult; - if (FailureMechanismResultViewHelper.SimpleAssessmentIsSufficient(simpleAssessmentResult)) - { - DataGridViewControl.DisableCell(eventArgs.RowIndex, eventArgs.ColumnIndex); - } - else - { - DataGridViewControl.RestoreCell(eventArgs.RowIndex, eventArgs.ColumnIndex); - } - } + new DataGridViewColumnFormattingRule( + new[] + { + 2, + 3 + }, + new Func[] + { + row => FailureMechanismResultViewHelper.SimpleAssessmentIsSufficient(row.SimpleAssessmentResult) + }, + (rowIndex, columnIndex) => DataGridViewControl.DisableCell(rowIndex, columnIndex), + (rowIndex, columnIndex) => DataGridViewControl.RestoreCell(rowIndex, columnIndex)) + }; } } } \ No newline at end of file