datagrid怎么设置才可以让用户编辑cell中的值,然后将用户编辑后的值保存到数据库中
晕死,现在连datagrid中的值都不可编辑。希望可以得到你们的提示,thanx!我试写过如下代码来让数据库保存用户编辑后的值
Private sub DataGrid1_AfterColEdit(byval ColIndex as integer)
a$=trim(DataGrid1.clomns(6).cellText(DataGrid1.book))
if a$<>"" then
if csn(a$)<>rs(6) then
rs(6)=csn(a$)
rs.update
datagrid1.refresh
endif
end if
End SubDataChanged 不知道怎么使用,msdn上的简单说明,好象可以很方便把数据更新到数据库
现在最想知道的是如何让datagrid可以允许用户编辑数据(datagrid是有数据源的)
请高手多指点
晕死,现在连datagrid中的值都不可编辑。希望可以得到你们的提示,thanx!我试写过如下代码来让数据库保存用户编辑后的值
Private sub DataGrid1_AfterColEdit(byval ColIndex as integer)
a$=trim(DataGrid1.clomns(6).cellText(DataGrid1.book))
if a$<>"" then
if csn(a$)<>rs(6) then
rs(6)=csn(a$)
rs.update
datagrid1.refresh
endif
end if
End SubDataChanged 不知道怎么使用,msdn上的简单说明,好象可以很方便把数据更新到数据库
现在最想知道的是如何让datagrid可以允许用户编辑数据(datagrid是有数据源的)
请高手多指点
a$=trim(DataGrid1.clomns(6).cellText(DataGrid1.book))
还有这句出现获取数据出错
我想控制columns("销售单价")那一列:在用户更改cell中的值时就更新到rs中,然后
rs.movefirst
for i=0 to rs.recordcount-1
sum=sum+rs(6)
next i
label1.caption=cstr(sum)来显示销售总额
rs.Open "select * from 表",cn,3,2
Set DataGrid1.DataSource=rs 'DataGrid1可编辑rs.Open "select f1*f2 as [f1*f2],f1+f2 as [f1+f2] from 表"
Set DataGrid1.DataSource=rs 'DataGrid1不可编辑,因为得到的记录集并不与表的列直接对应
如果你手动对DataGrid进行过编辑,建议你把它删了,重新添加一个DataGrid再试试
---------------------------------------
clomns(6)写错了,是clomns(6),而且DataGrid1至少要有7列,否则出错
rs.Open "select f1*f2 as [f1*f2],f1+f2 as [f1+f2] from 表"
Set DataGrid1.DataSource=rs 'DataGrid1不可编辑,
因为得到的记录集并不与表的列直接对应