DataView混淆 [英] DataView confusion

查看:65
本文介绍了DataView混淆的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有数据集和数据网格的表单。

我在这个数据集上创建了一个数据视图。

当用户修改数据网格时,我查找这条记录在数据视图中

以确保它是唯一的。


这是混乱.........

我认为DataView是来自数据集的视图,但似乎数据视图具有数据网格中的记录,因为每次我都会搜索a b $ b记录我知道不在数据集中,它找到它。我不能获得它。


有没有更好的方法在数据集中查找记录?这是我使用的代码。


Private Sub Button1_Click(ByVal sender As System.Object,ByVal e As

System.EventArgs)处理Button1.Click

Dim roomvar As String =

Me.DataGrid1.Item(Me.DataGrid1.CurrentRowIndex,0).ToString

Dim DV As New DataView( Ds1.Tables(房间))

DV.Sort =" roomno"

DV.RowFilter =" roomno like''" &安培; roomvar& "''"

Dim dr As DataRow


''用于调试............... 。

Label1.Text = Me.DataGrid1.Item(Me.DataGrid1.CurrentRowIndex,

0).ToString

Label2.Text = DV .Count.ToString

Label3.Text = DV.RowFilter.ToString

如果DV.Count> 0然后MsgBox(over)

End Sub

I have a form with a dataset and a datagrid.
I created a dataview on this dataset.
When the user modifies the datagrid, I look up this record in the dataview
to make sure it is unique.

Here is the confusion.........
I thought that the DataView is the view from the dataset, but it seems that
the dataview has the records that are in the datagrid, because everytime I
search for a record that I know is NOT in the dataset, it finds it. I don''t
get it.

Is there a better way to find a record in a dataset? Here is the code I use.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim roomvar As String =
Me.DataGrid1.Item(Me.DataGrid1.CurrentRowIndex, 0).ToString
Dim DV As New DataView(Ds1.Tables("rooms"))
DV.Sort = "roomno"
DV.RowFilter = "roomno like ''" & roomvar & "''"
Dim dr As DataRow

''Used to debug................
Label1.Text = Me.DataGrid1.Item(Me.DataGrid1.CurrentRowIndex,
0).ToString
Label2.Text = DV.Count.ToString
Label3.Text = DV.RowFilter.ToString
If DV.Count > 0 Then MsgBox("over")
End Sub

推荐答案

Steve Steve,

我先看了几遍这么一个小问题。
Hi Steve,

I have looked it then times over so a little question first.

这是混乱.........
我以为DataView是来自数据集的视图,但似乎
数据视图具有数据网格中的记录,因为每次我搜索我知道不在数据集中的记录时,它会发现它。我欠b $ b得不到它。

Here is the confusion.........
I thought that the DataView is the view from the dataset, but it seems that the dataview has the records that are in the datagrid, because everytime I
search for a record that I know is NOT in the dataset, it finds it. I don''t get it.



数据网格的数据源是什么?


如果是数据视图该数据视图的来源是什么?


Cor


What is the datasource from your datagrid?

And if it is a dataview what is the source of that dataview?

Cor


Datagrid源是一个数据集(DS1)

数据集源是一个Access数据库。

如果需要,这是我的DataGrid代码。


感谢您的帮助。

''------ DataGrid1 TABLESTYLE ----------------------


Dim ts作为DataGridTableStyle


DataGrid1.DataSource = Ds1


DataGrid1.DataMember =" rooms"


ts =新DataGridTableStyle

ts.MappingName =" rooms"


ts.PreferredRowHeight = 25

ts.AlternatingBackColor = System.Drawing.Color.FromArgb(CType(252,Byte),

CType(253,Byte),CType(206,Byte))


ts.HeaderBackColor = System.Drawing.Color.FromArgb(255,252,253,206)

ts.HeaderForeColor = System.Drawing.Color.Black


''------- dg_punch COLUMNSTYLES ----- -----------------


Dim tb1 As DataGridTextBoxColumn


tb1 =新DataGridTextBoxColumn


tb1.HeaderText ="房间号码>

tb1.MappingName =" roomno"


tb1.NullText =""


tb1.Width = 150

ts.GridColumnStyles.Add(tb1)


Dim tb2 As DataGridTextBoxColumn

tb2 =新DataGridTextBoxColumn


tb2.HeaderText ="房间描述"


tb2.MappingName =" roomdesc"


tb2.NullText =""


tb2.Width = 350

ts.GridColumnStyles.Add(tb2)


DataGrid1.TableStyles.Add(ts)


" Cor" < no*@non.com>在消息中写道

新闻:ON ************** @ TK2MSFTNGP09.phx.gbl ...
Datagrid source is a Dataset (DS1)
Dataset source is an Access database.
Here is my DataGrid code if needed.

Thank you for your help.

''------DataGrid1 TABLESTYLE----------------------

Dim ts As DataGridTableStyle

DataGrid1.DataSource = Ds1

DataGrid1.DataMember = "rooms"

ts = New DataGridTableStyle

ts.MappingName = "rooms"

ts.PreferredRowHeight = 25

ts.AlternatingBackColor = System.Drawing.Color.FromArgb(CType(252, Byte),
CType(253, Byte), CType(206, Byte))

ts.HeaderBackColor = System.Drawing.Color.FromArgb(255, 252, 253, 206)

ts.HeaderForeColor = System.Drawing.Color.Black

''-------dg_punch COLUMNSTYLES----------------------

Dim tb1 As DataGridTextBoxColumn

tb1 = New DataGridTextBoxColumn

tb1.HeaderText = "Room Number"

tb1.MappingName = "roomno"

tb1.NullText = ""

tb1.Width = 150

ts.GridColumnStyles.Add(tb1)

Dim tb2 As DataGridTextBoxColumn

tb2 = New DataGridTextBoxColumn

tb2.HeaderText = "Room Description"

tb2.MappingName = "roomdesc"

tb2.NullText = ""

tb2.Width = 350

ts.GridColumnStyles.Add(tb2)

DataGrid1.TableStyles.Add(ts)

"Cor" <no*@non.com> wrote in message
news:ON**************@TK2MSFTNGP09.phx.gbl...
嗨Steve,

我先看了几遍这么一个小问题。
Hi Steve,

I have looked it then times over so a little question first.

这是混乱.........
我以为DataView是来自数据集的视图,但似乎

Here is the confusion.........
I thought that the DataView is the view from the dataset, but it seems


dataview具有datagrid中的记录,因为每次
我搜索我知道的记录不在数据集中,它找到了它。我
the dataview has the records that are in the datagrid, because everytime I search for a record that I know is NOT in the dataset, it finds it. I


不要

得到它。


数据网格的数据源是什么?

如果它是数据视图数据视图的来源是什么?


What is the datasource from your datagrid?

And if it is a dataview what is the source of that dataview?

Cor



您好Steve,

如果我理解错误,请纠正我,但是你的
datagrid1上的所有内容都在你的Ds1.tables(房间)中


现在我很奇怪那个数据集中不能存在什么以及从哪里获得

那个数据?

数据集当然可以有更多的列, (我没有看到你的选择

声明,而不是我需要的声明)


如果是访问权限或SQL数据库对此并不重要。


Cor
Hi Steve,

Correct me if I understand it wrong, but everything that is on your
datagrid1 is in your Ds1.tables("rooms")

And now I am currious what cannot be in that dataset and from where you get
that data?
The dataset can of course have more columns, (I did not see your select
statement, not that I needed that)

If it is an access or an SQL database is not important for this.

Cor
Datagrid源是一个数据集(DS1)
数据集源是一个Access数据库。
这是我的DataGrid代码如果需要的话。

感谢您的帮助。

'' ------ DataGrid1 TABLESTYLE ----------------------

Dim ts As DataGridTableStyle

DataGrid1.DataSource = Ds1

DataGrid1.DataMember =" rooms"

ts =新DataGridTableStyle

ts.MappingName =" rooms"

ts.PreferredRowHeight = 25
ts.AlternatingBackColor = System.Drawing.Color.FromArgb(CType(252,Byte),
CType(253,Byte), CType(206,Byte))

ts.HeaderBackColor = System.Drawing.Color.FromArgb(255,252,253,206)
ts.HeaderForeColor = System.Drawing .Color.Black

''------- dg_punch COLUMNSTYLES ----------------------

Dim tb1 As DataGridTextBoxColumn

tb1 = New DataGridTextBoxColumn

tb1.HeaderText =" Room Number"

tb1.MappingName =" roomno"

tb1.NullText =""

tb1.Width = 150

ts.GridColumnStyles.Add(tb1)

Dim tb2 As DataGridTextBoxColumn

tb2 =新的DataGridTextBoxColumn

tb2.HeaderText ="房间描述"

tb2.MappingName =" roomdesc"

tb2。 NullText =""

tb2.Width = 350

ts.GridColumnStyles.Add(tb2)

DataGrid1.TableStyles.Add(ts )

Cor < no*@non.com>在消息中写道
新闻:ON ************** @ TK2MSFTNGP09.phx.gbl ...
Datagrid source is a Dataset (DS1)
Dataset source is an Access database.
Here is my DataGrid code if needed.

Thank you for your help.

''------DataGrid1 TABLESTYLE----------------------

Dim ts As DataGridTableStyle

DataGrid1.DataSource = Ds1

DataGrid1.DataMember = "rooms"

ts = New DataGridTableStyle

ts.MappingName = "rooms"

ts.PreferredRowHeight = 25

ts.AlternatingBackColor = System.Drawing.Color.FromArgb(CType(252, Byte),
CType(253, Byte), CType(206, Byte))

ts.HeaderBackColor = System.Drawing.Color.FromArgb(255, 252, 253, 206)

ts.HeaderForeColor = System.Drawing.Color.Black

''-------dg_punch COLUMNSTYLES----------------------

Dim tb1 As DataGridTextBoxColumn

tb1 = New DataGridTextBoxColumn

tb1.HeaderText = "Room Number"

tb1.MappingName = "roomno"

tb1.NullText = ""

tb1.Width = 150

ts.GridColumnStyles.Add(tb1)

Dim tb2 As DataGridTextBoxColumn

tb2 = New DataGridTextBoxColumn

tb2.HeaderText = "Room Description"

tb2.MappingName = "roomdesc"

tb2.NullText = ""

tb2.Width = 350

ts.GridColumnStyles.Add(tb2)

DataGrid1.TableStyles.Add(ts)

"Cor" <no*@non.com> wrote in message
news:ON**************@TK2MSFTNGP09.phx.gbl...
史蒂夫,
Hi Steve,

I have looked it then times over so a little question first.

这是混乱.........
我以为DataView是来自数据集的视图,但似乎

Here is the confusion.........
I thought that the DataView is the view from the dataset, but it seems that
dataview具有datagrid中的记录,因为
the dataview has the records that are in the datagrid, because


每次我搜索我知道不在的记录数据集,它找到它。我

everytime I search for a record that I know is NOT in the dataset, it finds it. I


不要

得到它。


数据网格的数据源是什么?

如果它是数据视图数据视图的来源是什么?


What is the datasource from your datagrid?

And if it is a dataview what is the source of that dataview?

Cor




这篇关于DataView混淆的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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