捕获空的数据行. [英] Catch empty datarow.

查看:112
本文介绍了捕获空的数据行.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好.
我对BindingSource"NewRow"有疑问.
我想检查BindingSource对象的新添加的行是否为空".
新的" BindingSource行"是指用户单击BindingSourceNavigator栏中的黄色加号(+)时生成的新行.(AddNew-method)
空"是指一个新的数据行,其中所有字段"均为"nullValue".
当然,条件是没有定义任何默认值,并且所有字段都必须允许使用"nullvalue".

所以问题是:
我如何检查(例如,在form_closing事件中)BindingSource新行的至少一个字段不是nullvlue?

为了使答案尽可能简单",我们可以考虑检查的行是BindingSource的当前项.
(知道BindingSource中最后添加的行的位置属性为:BS.count-1)

谢谢

Hi all.
I have a question about the BindingSource "NewRow".
I would like to check if a newly added row of a BindingSource-object is "empty".
By a "new" BindingSource "row" i mean the new row which is generated when the user clicks the yellow plus-sign (+) in the BindingSourceNavigatorbar.(AddNew-method)
And by "empty" i mean a new datarow where all the "fields" are "nullValue".
Condition for that, of course is that no default values are defined and "nullvalue" must be allowed for all the fields.

So the question is:
How can i check (f.ex. in the form_closing event) that at least one of the fields of the new row of the BindingSource is not nullvlue?

In order to keep the answer as "simple" as possible we can consider that the row to check is the current item of the BindingSource.
(knowing that the position-property of the last added row in a BindingSource is: BS.count - 1)

Thanks

推荐答案

您似乎经验丰富,因此,如果这告诉您您已经知道的内容,请原谅我.

BindingSource返回的行可以强制转换为 DataRowView [^ ].

DataRowView具有Items属性,该属性可以通过其整数位置和名称进行索引.

因此,您可以遍历DataRowView,检查每个项目是否为DBNull.Value或null(适用于您的情况).
You seem to be reasonably experienced, so forgive me if this is telling you something you already know.

The row returned from a BindingSource is able to be cast to a DataRowView[^].

DataRowView Has an Items property which can be indexed by both its integer position and its name.

You can therefore iterate over the DataRowView checking each item for DBNull.Value or null, whichever is applicable to your situation.


亨利·分钟(Henry Minute).
感谢您的快速答复.
因此,您写道可以将BindingSource的行强制转换为DataRowView.
是的,这是一件好事,我经常使用它.
如果我将其放入代码中,可能类似于:
Hi Henry Minute.
Thank you for your fast reply.
So you wrote that the rows of a BindingSource can be cast to DataRowView.
Yes that''s a good thing and i use it quite often.
If i put it into code it could be something like:
Dim myDRV As DataRowView = CType(Me.myBS.Current, DataRowView)


您说我可以再迭代myDRV的项目.
但是我不知道该怎么做!
我找不到myDRV的 Items 属性.
intelisense中显示的唯一属性是 Item 属性,该属性需要整数或字段名称作为字符串.

您能(用几行代码)告诉我如何迭代这些项目吗?那将对我有很大帮助.

我已经尝试过For/Next循环,但是正如我已经提到的.我找不到用于迭代槽的集合.

谢谢.


You said i could then iterate myDRV''s items.
But i can''t find out how to do that!
I cant find no Items property of myDRV.
The only property that shows up in intelisense is the Item property which needs an integer or the field''s name as string.

Could you please show me (with a few lines of code) how to iterate these Items? That would help me quite a lot.

I have tried it with a For/Next loop, but as i already mentioned. I cant find the collection to iterate trough.

Thank you.


这篇关于捕获空的数据行.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆