首页 > 开发 > 综合 > 正文

后台更新DataTable行内容的方法

2024-07-21 02:22:54
字体:
来源:转载
供稿:网友
这几天一直在找绑定后后台修改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();
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表