Skip to content

Instantly share code, notes, and snippets.

@kyle-seongwoo-jun
Created November 26, 2018 08:22
Show Gist options
  • Save kyle-seongwoo-jun/371f2f55849daa1125d6b46bd226c3f0 to your computer and use it in GitHub Desktop.
Save kyle-seongwoo-jun/371f2f55849daa1125d6b46bd226c3f0 to your computer and use it in GitHub Desktop.
namespace WinFormsUtil
{
public static class ListViewUtils
{
public static void SetSource<T>(this ListView.ListViewItemCollection items, IEnumerable<T> source, Func<T, ListViewItem> func)
{
items.Clear();
items.AddRange(source.Select(func).ToArray());
}
public static void SetSource<T>(this ListView.ListViewItemCollection items, IEnumerable<T> source, Func<T, int, ListViewItem> func)
{
items.Clear();
items.AddRange(source.Select(func).ToArray());
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment