当通过programaticaly设置列值时,Datagridview不会自动生成行 [英] Datagridview doesnt automaticaly generate row when column values are set by programaticaly
本文介绍了当通过programaticaly设置列值时,Datagridview不会自动生成行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好专家....
我有一个包含name,qty,rate,total列的网格,datagridview属性设置为AllowUsersToAdd
当我手动输入详细信息到列时,会自动生成一个新行,
但是当我通过编程设置列值时它不会生成新的我想怎么解决这个问题?
我试过google但结果是一样的...
请帮我一些代码或参考资料
提前谢谢
Hello experts....
I have a grid containing columns "name,qty,rate,total" and the datagridview property is set to AllowUsersToAdd
when i manually enter details to column a new row is automatically generated,
but when i set the column values by programatically it doesnt generate a new row
how can i solve this?
I tried with editmode,But nothing works well for me
I tried google but the result is same...
Please help me with some code or references
Thanks in advance
推荐答案
我怀疑在以编程方式添加行之后,需要将datagrid重新绑定到数据源。
I suspect that after you add the row programatically you need to rebind the datagrid to the datasource.
使用BindingList对象绑定Grid的数据源。
对BindingList对象的任何修改(添加/删除)都将导致组件模型对象刷新。因此UI元素将自动刷新而不调用后端中的任何显式方法。
Bind the datasource of the Grid using BindingList object.
Any modification to BindingList object (add/remove) will cause the component model object to refresh. So the UI element will auto refresh without calling any explicit methods in the backend.
这篇关于当通过programaticaly设置列值时,Datagridview不会自动生成行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文