diff --git a/LibationWinForms/AsyncNotifyPropertyChanged.cs b/LibationWinForms/AsyncNotifyPropertyChanged.cs index 96f007ed..136930aa 100644 --- a/LibationWinForms/AsyncNotifyPropertyChanged.cs +++ b/LibationWinForms/AsyncNotifyPropertyChanged.cs @@ -8,7 +8,7 @@ namespace LibationWinForms { public event PropertyChangedEventHandler PropertyChanged; - protected void NotifyPropertyChanged([CallerMemberName] string propertyName = "") + public void NotifyPropertyChanged([CallerMemberName] string propertyName = "") => this.UIThread(() => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName))); } } diff --git a/LibationWinForms/GridEntry.cs b/LibationWinForms/GridEntry.cs index 35f08030..857469c6 100644 --- a/LibationWinForms/GridEntry.cs +++ b/LibationWinForms/GridEntry.cs @@ -60,7 +60,6 @@ namespace LibationWinForms //DisplayTags and Liberate properties are live. } - public void NotifyChanged() => NotifyPropertyChanged(nameof(GridEntry)); private void PictureStorage_PictureCached(object sender, FileManager.PictureCachedEventArgs e) { diff --git a/LibationWinForms/ProductsGrid.cs b/LibationWinForms/ProductsGrid.cs index 246c97c8..238f102d 100644 --- a/LibationWinForms/ProductsGrid.cs +++ b/LibationWinForms/ProductsGrid.cs @@ -101,7 +101,9 @@ namespace LibationWinForms //Re-apply filters Filter(); - liveGridEntry.NotifyChanged(); + + //Update whole GridEntry row + liveGridEntry.NotifyPropertyChanged(); } #endregion @@ -150,10 +152,10 @@ namespace LibationWinForms public void RefreshRow(string productId) { - var rowIndex = getRowIndex((ge) => ge.AudibleProductId == productId); + var liveGridEntry = getRowItem((ge) => ge.AudibleProductId == productId); - // update cells incl Liberate button text - _dataGridView.InvalidateRow(rowIndex); + // update GridEntry Liberate cell + liveGridEntry?.NotifyPropertyChanged(nameof(liveGridEntry.Liberate)); // needed in case filtering by -IsLiberated and it gets changed to Liberated. want to immediately show the change Filter(); @@ -194,7 +196,9 @@ namespace LibationWinForms #region DataGridView Macro - private int getRowIndex(Func func) => _dataGridView.GetRowIdOfBoundItem(func); + private GridEntry getRowItem(Func predicate) + => ((SortableBindingList)gridEntryBindingSource.DataSource).FirstOrDefault(predicate); + private GridEntry getGridEntry(int rowIndex) => _dataGridView.GetBoundItem(rowIndex); #endregion