I'm trying to set up a ListView that will output all the results from a search query with LiteDB. Unfortunately, I'm having trouble finding a way to get the results into the ProductName string format. I've tried multiple different ways to no success. The code below clearly isn't right. However, is just a quick example of what I'm trying to do.
private void SearchButton_Click(object sender, EventArgs e)
{
listView1.Items.Clear();
using (var db = new LiteDatabase(@"C:\Temp\MyData.db"))
{
var collection = db.GetCollection<Product>("Product");
var results = collection.Find(x => x.ProductName.StartsWith(textBox1.Text));
foreach(var item in results)
{
listView1.Items.Add(item.ToString());
}
}
}
I expected the results to be the ProductName in a string format, however, it only outputs "StockMngr.Product" to the listview, StockMngr being the name of the project.