开发者

Unbound column value disapears from DataGridView on sort

开发者 https://www.devze.com 2022-12-12 03:54 出处:网络
I have a DataGridView bound to a DataTable (it was bound to a List(of T) but the DataGridView is much more performant).

I have a DataGridView bound to a DataTable (it was bound to a List(of T) but the DataGridView is much more performant).

I add an extra DataGridViewLinkColumn to the DataGridView (the value of this column is set to equal the value of one of the bound columns, I just need it to show as a link).

The problem is when I sort the DataGridView by clicking on a header the values in the unbound column clears.

Do I need 开发者_如何学编程to loop through the rows each time to reset the values, or is there a better way of getting a DataGridViewLinkColumn as one of my bound columns?


Create a new class 'TRow' with all the fields you need from T, plus the link, and bind to a DataTable of TRow objects. The extra column will now be a bound column instead of unbound and your sorting should work.

0

精彩评论

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

关注公众号