开发者

Best way to keep a DataGridView up to date in c#

I want to add a filter textbox to an application so that when a user types text into it, as they type it, the DataGridView will automatically trim down what's being viewed.

Right now DataGridView is bound to a List with my User Objects.

I was in the process of just using LINQ to create a separate List of User objects开发者_StackOverflow社区 and then just re update the DataGridView by doing the whole dataGridView1.DataSource = filteredList but is that the best way to go about this? I feel like I'm doing it the bad way.


Your "filteredList" should be a bindingList just so you create a direct interaction between the list and the grid (modifying the grid will modify the list without you having to do any more step).


That's probably similar to what I'd go with. Alternatively you could iterate the list and remove any objects no longer matching which will probably be much more memory-friendly.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜