这几天一直在找绑定后后台修改datatable行这方面的代码,发现很少,但是又不得不实现这样的功能,通过查帮助,自己解决了:)
我是将datatable绑定到listbox上,通过修改datatable来修改listbox值
listbox1.beginupdate(); // stop the listbox from drawing while items are added.
datatable dt;
int indexnum=listbox1.selectedindex;
dt=(datatable)listbox1.datasource;
datarow custrow = dt.rows[indexnum];
custrow.beginedit();
custrow[0] = indexnum;
custrow[1]="after modify";
custrow.endedit();
dt.acceptchanges();
listbox1.endupdate();// end the update process and force a repaint of the listbox.
listbox1.update();
listbox1.beginupdate(); // stop the listbox from drawing while items are added.
datatable dt;
int indexnum=listbox1.selectedindex;
dt=(datatable)listbox1.datasource;
datarow custrow = dt.rows[indexnum];
custrow.beginedit();
custrow[0] = indexnum;
custrow[1]="after modify";
custrow.endedit();
dt.acceptchanges();
listbox1.endupdate();// end the update process and force a repaint of the listbox.
listbox1.update();