I am newbie I have tried to bind simply HashSet
as DataSource
of DataGridView, but still has any item in GridView
dataGridViewBookList.DataSource = null;
dataGridViewBookList.DataSource = bookContainer;
Creating hash set
bookContainer = new HashSet<BookModel>();
dataGridViewBookList.DataSource = bookContainer;
BookModel class
class BookModel
{
public string Name { get; set; }
public uint Year { get; set; }
public string Series { get; set; }
public string Pulbisher { get; set; }
public string Author { get; set; }
public string Language { get; set; }
public uint PagesCount { get; set; }
}
Please help to bind hash set to GridView. Sorry for this question I am newbie in C#.
Thank you so much.
Try this
var book = new BookModel//fill it with your data
{
Author = "a",
Language = "l",
Name = "n",
PagesCount = 0,
Pulbisher = "p",
Series = "s",
Year = 1990
};
var list=new List<BookModel>();
list.Add(book);
var bookContainer = new HashSet<BookModel>(list);//you have to pass list to HashSet constructor
dataGridViewBookList.DataSource = bookContainer.ToList();