wpf - Wrong index after re-ordering datagrid rows -


i have data table bound data grid, , when re-order rows, index of string i'm looking gets messed up.

i index of serial num column... works, after i've moved it.

dim snindex integer = asset_masterdatagrid.columns.[single](function(c) c.header.tostring() = "serial num").displayindex  

then direct cast row i'm clicking

dim item datarowview = directcast(asset_masterdatagrid.selecteditem, datarowview) 

then grab string of cell in serial num column.

 dim sn string = item.row(snindex) 

enter image description here of course doesn't work, , when re-order serial number column lets say... index 0, grabs asset id cell string. i'm trying find serial number of whatever row click on, no matter serial number column is.

any ideas on how correct issue?

you can access column of datarowview name rather index:

dim item datarowview = directcast(asset_masterdatagrid.selecteditem, datarowview) dim sn string = item("serial num") 

this should work provided know name of serial number column.


Comments

Popular posts from this blog

How to understand 2 main() functions after using uftrace to profile the C++ program? -

c# - Update a combobox from a presenter (MVP) -

How to put a lock and transaction on table using spring 4 or above using jdbcTemplate and annotations like @Transactional? -