Windows在选择最后一行时形成DataGridView绑定保存 [英] Windows forms DataGridView binding save when last row is selected
问题描述
您好,
将DataGridView与数据源和defaultvalues一起使用时,我遇到了一些问题。
I'm having some problems when using DataGridView with a datasource and defaultvaluesneeded.
我有一个网格限制到BindingList,当我尝试保存时,如果选择了最后一行,那么我在最后一行的BindingList中有一个额外的条目。它只有defaultvaluesneeded的值。
I have a grid bounded to a BindingList and when i try to Save, if the last row is selected, than i have an extra entry in the BindingList for that last row. It has only the values from defaultvaluesneeded.
有没有办法阻止它?
提前致谢,
Sergiu
最好的问候。
推荐答案
看起来你需要首先检查最后一行是否在发出save方法之前有任何默认值,因为DataGridView没有这个作为检查,它在你的控制之下。您可以通过查询基础数据
来检查行,而不是主键值与切线相关,确定是否有任何或所有字段都有默认值。
Seems like you would need to first check to see if the last row has any default values prior to issuing the save method as a DataGridView does not have this as a check, it's under your control. You could check for the row by querying the underlying data for a row without a primary key value in tangent with determining if any or all fields have default values.
这篇关于Windows在选择最后一行时形成DataGridView绑定保存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!