c# - Dataview doesn't get datagridview column header properly -


though set new column header in datatable before assigning datagridview, when call datagridview dataview old column headers. here part of code:

dataset ds = new dataset(); grid.datasource = null; ds.readxml(path); var dt = ds.tables[0];  dt.columns["name"].caption = "descr"; dt.columns["account"].caption = "acnt"; // tried both .caption , .columname  grid.datasource = ds.tables[0]; 

i tried changing column header after implementation of datagridview, still without result:

grid.columns[0].headertext = "descr"; 

how can set column header later dataview can read properly?

you need set datapropertyname, in case:

dt.columns["name"].datapropertyname = "name"; dt.columns["name"].headertext = "descr";  dt.columns["account"].datapropertyname = "account"; dt.columns["account"].headertext = "acnt"; 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -