generate functionTue, 07 Feb 2023

listcollectionview filtering current month

public class DateComparer : IComparer<DateTime> { public int Compare(DateTime x, DateTime y) { if (x.Year == y.Year && x.Month == y.Month) return 0; return 1; } } //... ListCollectionView lstCollView = new ListCollectionView(lst); lstCollView.Filter = (obj) => { DateTime dt = (DateTime)obj; if (dt.Year == DateTime.Now.Year && dt.Month == DateTime.Now.Month) return true; return false; };

Questions about programming?Chat with your personal AI assistant