简体   繁体   中英

winform C# DataGridView How to Update Columns bound to Generic List

Currently I have a DataGridView that is bound to a Generic List. So I have:

dataGridView1.DataSource = ProductBO.GetProducts(); 

This displays about 300 products and need the ability to update the price and quantity columns when needed. Whats the easiest/cleanest way? There must be some event like to use txtPrice_AfterUpdate() that can be used. Coming from a Webform backgraound and MS Access Im not sure the route to take here. Thanks in advance.

Unless it's a really expensive operation you could just refresh the DataSource, literally call that code again.

public void RefreshProducts()
{
    dataGridView1.DataSource = ProductBO.GetProducts();
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM