Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/DesignWaterLevelLocationsView.cs =================================================================== diff -u -r161308cb864a66713f62357c6bcdb6ede03b619f -r75fe077813084ef8a06b38bd149cf443acf73d27 --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/DesignWaterLevelLocationsView.cs (.../DesignWaterLevelLocationsView.cs) (revision 161308cb864a66713f62357c6bcdb6ede03b619f) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/DesignWaterLevelLocationsView.cs (.../DesignWaterLevelLocationsView.cs) (revision 75fe077813084ef8a06b38bd149cf443acf73d27) @@ -41,6 +41,7 @@ /// public partial class DesignWaterLevelLocationsView : UserControl, ISelectionProvider { + private const int locationCalculateColumnIndex = 0; private readonly Observer assessmentSectionObserver; private readonly Observer hydraulicBoundaryDatabaseObserver; private IAssessmentSection assessmentSection; @@ -112,6 +113,7 @@ private void InitializeDataGridView() { dataGridViewControl.AddCellClickHandler(DataGridViewOnCellClick); + dataGridViewControl.AddCellValueChangedHandler(DataGridViewCellValueChanged); dataGridViewControl.AddCheckBoxColumn(TypeUtils.GetMemberName(row => row.ToCalculate), Resources.HydraulicBoundaryLocationsView_Calculate); @@ -136,6 +138,7 @@ new DesignWaterLevelLocationContext(assessmentSection.HydraulicBoundaryDatabase, hl))).ToArray() : null); updatingDataSource = false; + UpdateCalculateForSelectedButton(); } private IEnumerable GetDesignWaterLevelLocationContextRows() @@ -148,8 +151,22 @@ return GetDesignWaterLevelLocationContextRows().Where(r => r.ToCalculate).Select(r => r.HydraulicBoundaryLocationContext.HydraulicBoundaryLocation); } + private void UpdateCalculateForSelectedButton() + { + CalculateForSelectedButton.Enabled = GetDesignWaterLevelLocationContextRows().Any(r => r.ToCalculate); + } + #region Event handling + private void DataGridViewCellValueChanged(object sender, DataGridViewCellEventArgs e) + { + if (updatingDataSource || e.ColumnIndex != locationCalculateColumnIndex) + { + return; + } + UpdateCalculateForSelectedButton(); + } + private void DataGridViewOnCellClick(object sender, DataGridViewCellEventArgs e) { if (updatingDataSource) @@ -192,12 +209,14 @@ { GetDesignWaterLevelLocationContextRows().ForEachElementDo(row => row.ToCalculate = true); dataGridViewControl.RefreshDataGridView(); + UpdateCalculateForSelectedButton(); } private void DeselectAllButton_Click(object sender, EventArgs e) { GetDesignWaterLevelLocationContextRows().ForEachElementDo(row => row.ToCalculate = false); dataGridViewControl.RefreshDataGridView(); + UpdateCalculateForSelectedButton(); } private void CalculateForSelectedButton_Click(object sender, EventArgs e)