认为应该是简单的但是很难找到信息:( [英] Think is should be simple but carn`t find info:(

查看:73
本文介绍了认为应该是简单的但是很难找到信息:(的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hey Group,


我当然这很简单,但我似乎随时都找不到任何信息:(


我有2 x表格:表格1上有一个DataConnecter和几个DataAdapter,

全部绑定在我的DataSet中。


在我的桌子上(传真)我有与另一个表(MeterReadings)的关系,

我的表格我有一个名为Meter Reading的按钮。


如何获得它以便当我从我的数据网格中的数据库中选择一行
我的Form1上的
,然后点击Meter Reading时,它会将Form2与Datagrid一起加载

只显示我的仪表读数对于我在表格1上选择的传真行?如果

你明白了我的意思


任何链接帮助都会受到很大关注。


非常感谢

MCN

Hey Group,

Im Sure this is simple but I carn`t seem to find any info anywhere:(

I have 2 x Forms: Form 1 has a DataConnecter and several DataAdapters on it,
all bound together in my DataSet.

On My Table(Faxs) I have a relationship to another Table(MeterReadings), on
my Form I have a button called "Meter Reading".

How do I get it so that when I select a row from my Database in my datagrid
on my Form1, and click Meter Reading, it loads up Form2 with a Datagrid that
only shows me the meter Readings for the Fax Row I selected on Form 1? If
you get what I mean

Any Links Are help would be greatly appriciated.

Many Thanks
MCN

推荐答案

请使用两个组(或全部)标题中的群组,所以你不要多次使用)

我在ADO.N中回答了这个问题。 ET和我相信我有一个更完整的答案

之前的同样的问题,但我现在似乎没有看到它。


DataRow dro = DataTable.Rows [dataGrid.SelectedRowIndex];


然后将dro传递给您的新表单。您可以在新的

表单中创建属性,也可以创建一个重载的构造函数或函数,将数据行

作为参数然后绑定到它。


HTH,


比尔

www.devbuzz.com
www.knowdotnet .com


" MadCrazyNewbie" < TE ** @ nospam.com>在消息中写道

新闻:0f ******************** @ karoo.co.uk ...
Please use both groups (or all groups in the header so you don''t mulitpost)
I answered this over in ADO.NET and I believe I had a more complete answer
to the same problem previously but i don''t seem to see it right now.

DataRow dro = DataTable.Rows[dataGrid.SelectedRowIndex];

then pass dro to your new form. You can either create a property in the new
form, or create an overloaded constructor or function that takes a datarow
as a param and then bind to it.

HTH,

Bill

www.devbuzz.com
www.knowdotnet.com

"MadCrazyNewbie" <te**@nospam.com> wrote in message
news:0f********************@karoo.co.uk...
嘿小组,

我当然这很简单但我似乎无处可寻找任何信息:(

我有2个表格:表格1有一个DataConnecter和
上的几个DataAdapter,全部绑定在我的DataSet中。

在我的表(传真)上我与另一个表(MeterReadings)有关系,
在我的表格上我有一个名为Meter Reading的按钮。

如何获取它,以便当我在Form1上的
数据网格中从我的数据库中选择一行,然后单击Meter Reading时,它会加载Form2带有一个Datagrid
,它只显示我在Form 1上选择的传真行的读数?如果
你明白我的意思

任何链接都有帮助非常感谢。

非常感谢
MCN
Hey Group,

Im Sure this is simple but I carn`t seem to find any info anywhere:(

I have 2 x Forms: Form 1 has a DataConnecter and several DataAdapters on it, all bound together in my DataSet.

On My Table(Faxs) I have a relationship to another Table(MeterReadings), on my Form I have a button called "Meter Reading".

How do I get it so that when I select a row from my Database in my datagrid on my Form1, and click Meter Reading, it loads up Form2 with a Datagrid that only shows me the meter Readings for the Fax Row I selected on Form 1? If
you get what I mean

Any Links Are help would be greatly appriciated.

Many Thanks
MCN



Hi Mad,


我正忙着告诉你和William对多重信号的看法一样,我s

你跨站点(发送一条消息给更多的新闻组)比没有问题

其他人可以看看你在adonet组中得到的答案是否适合

你。


因为我很忙,并且采用了另一种方法而不是威廉我也发送了这个。


你说你有做了一个datarelation,我希望使用

setdatabinding绑定到数据集。在我看来,你可以做的事情如下:


\\\

Dim frm As New Form2

frm .DataGrid1.SetDataBinding(ds,_

" Maintable.DatarelationName")

frm.ShowDialog()

///


我希望这有帮助吗?

Cor

Hi Mad,

I was busy telling you the same as William did about the multipost, there is
no problem when you crosspost (send one message to more newsgroups) than
others can see if the answer you did get in the adonet group was right for
you.

Because I was busy and with another approach than William I send this also.

You said you had a made a datarelation and I hope binded the maintable using
setdatabinding to the dataset. Than you can do in my opinion something as:

\\\
Dim frm As New Form2
frm.DataGrid1.SetDataBinding(ds, _
"Maintable.DatarelationName")
frm.ShowDialog()
///

I hope this helps?
Cor


Cor,


对不起,我不明白你的意思是使用

setdatabings绑定主表?


这是我的代码:


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

As System.EventArgs)处理MyBase.Load

cmDsFax = BindingContext (dsFax,传真)

cmDsPhotoCopiers = BindingContext(dsPhotocopiers,PhotoCopiers)

mlLoading = True

''开始填写数据集

尝试

dsFax.EnforceConstraints = False

dsPhotocopiers.EnforceConstraints = True

尝试

Me.od cFaxCopiers.Open()

''填写传真复印机数据集

Me.odaDepartments.Fill(dsFax)

Me.odaSites.Fill(dsFax )

Me.odaFaxs.Fill(dsFax)

''填写PhotoCopier数据集

Me.odaDepartments.Fill(dsPhotocopiers)

Me.odaSites.Fill(dsPhotocopiers)

Me.odaPhotoCopiers.Fill(dsPhotocopiers)

Catch fillException As System.Exception

抛出fillException

最后

Me.odcFaxCopiers.Close()

结束尝试

Catch eLoad As System.Exception

System.Windows.Forms.MessageBox.Show(eLoad.Message)

最后

mlLoading = False

结束尝试

''填充数据集结束

结束子


''开始更改位置代码 - 传真
Private Sub cmdsFax_PositionChanged(ByVal sender As Object,ByVal e As

System.EventArgs)处理cmDsFax.PositionChanged

dsFax_PositionChanged()

En d Sub

Private Sub cboFaxsDepartment_SelectedIndexChanged(ByVal sender As

Object,ByVal e As System.EventArgs)Handles

cboFaxsDepartment.SelectedIndexChanged

Me.BindingContext(dsFax," Faxs")。EndCurrentEdit()

如果是Me.BindingContext(dsFax,传真)。位置<> -1而不是mlLoading

然后

dsFax.Faxs.Rows(Me.BindingContext(dsFax,

" Faxs")。Position) .Item(" DepartmentID")= Me.cboFaxsDepartment.SelectedValue

结束如果

结束子

私有子cbofaxsSite_SelectedIndexChanged(ByVal sender As Object ,

ByVal e As System.EventArgs)处理cboFaxsSite.SelectedIndexChanged

Me.BindingContext(dsFax," Faxs")。EndCurrentEdit()

如果是Me.BindingContext(dsFax,Faxs)。Position<> -1而不是mlLoading

然后

dsFax.Faxs.Rows(Me.BindingContext(dsFax,

" Faxs")。Position) .Item(" SitesID")= Me.cboFaxsDepartment.SelectedValue

结束如果

结束子

私有子dsFax_PositionChanged()

Me.BindingContext(dsFax," Faxs")。EndCurrentEdit()

如果是Me.BindingContext(dsFax,传真)。位置<> -1而不是mlLoading

然后

Me.cboFaxsDepartment.SelectedValue =

dsFax.Faxs.Rows(Me.BindingContext(dsFax,

" Faxs"。)Position。。Item(" DepartmentID")

Me.cboFaxsSite.SelectedValue = dsFax.Faxs.Rows(Me.BindingContext(dsFax,

" Faxs"。)。Position).Item(" SitesID")

结束如果

结束子


很多人再次感谢

MCN


''结束位置更改代码 - 传真

" Cor Ligthert" <无********** @ planet.nl>在消息中写道

news:OU ************** @ TK2MSFTNGP09.phx.gbl ...
Cor,

Sorry I don`t understand what you mean bind the main table using
setdatabings?

Here is my code:

Private Sub frmMainMenuPasswords_Load(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles MyBase.Load
cmDsFax = BindingContext(dsFax, "Faxs")
cmDsPhotoCopiers = BindingContext(dsPhotocopiers, "PhotoCopiers")
mlLoading = True
''Start of Fill Datasets
Try
dsFax.EnforceConstraints = False
dsPhotocopiers.EnforceConstraints = True
Try
Me.odcFaxCopiers.Open()
''Fill Fax Copier Datasets
Me.odaDepartments.Fill(dsFax)
Me.odaSites.Fill(dsFax)
Me.odaFaxs.Fill(dsFax)
''Fill PhotoCopier Datasets
Me.odaDepartments.Fill(dsPhotocopiers)
Me.odaSites.Fill(dsPhotocopiers)
Me.odaPhotoCopiers.Fill(dsPhotocopiers)
Catch fillException As System.Exception
Throw fillException
Finally
Me.odcFaxCopiers.Close()
End Try
Catch eLoad As System.Exception
System.Windows.Forms.MessageBox.Show(eLoad.Message )
Finally
mlLoading = False
End Try
''End of Fill Datasets
End Sub

''Start of Position Changed Code - Faxs
Private Sub cmdsFax_PositionChanged(ByVal sender As Object, ByVal e As
System.EventArgs) Handles cmDsFax.PositionChanged
dsFax_PositionChanged()
End Sub
Private Sub cboFaxsDepartment_SelectedIndexChanged(ByVal sender As
Object, ByVal e As System.EventArgs) Handles
cboFaxsDepartment.SelectedIndexChanged
Me.BindingContext(dsFax, "Faxs").EndCurrentEdit()
If Me.BindingContext(dsFax, "Faxs").Position <> -1 And Not mlLoading
Then
dsFax.Faxs.Rows(Me.BindingContext(dsFax,
"Faxs").Position).Item("DepartmentID") = Me.cboFaxsDepartment.SelectedValue
End If
End Sub
Private Sub cbofaxsSite_SelectedIndexChanged(ByVal sender As Object,
ByVal e As System.EventArgs) Handles cboFaxsSite.SelectedIndexChanged
Me.BindingContext(dsFax, "Faxs").EndCurrentEdit()
If Me.BindingContext(dsFax, "Faxs").Position <> -1 And Not mlLoading
Then
dsFax.Faxs.Rows(Me.BindingContext(dsFax,
"Faxs").Position).Item("SitesID") = Me.cboFaxsDepartment.SelectedValue
End If
End Sub
Private Sub dsFax_PositionChanged()
Me.BindingContext(dsFax, "Faxs").EndCurrentEdit()
If Me.BindingContext(dsFax, "Faxs").Position <> -1 And Not mlLoading
Then
Me.cboFaxsDepartment.SelectedValue =
dsFax.Faxs.Rows(Me.BindingContext(dsFax,
"Faxs").Position).Item("DepartmentID")
Me.cboFaxsSite.SelectedValue = dsFax.Faxs.Rows(Me.BindingContext(dsFax,
"Faxs").Position).Item("SitesID")
End If
End Sub

Many Again Thanks
MCN

''End of Position Changed Code - Faxs
"Cor Ligthert" <no**********@planet.nl> wrote in message
news:OU**************@TK2MSFTNGP09.phx.gbl...
嗨Mad,

我正忙着告诉你和William对多重邮件的看法一样,当你跨站点(向一个新闻组发送一条消息)时,
没问题,而其他人可以看到答案你确实进入adonet组是对的。

因为我很忙,而且还有另一种方法,而不是威廉,我也发了这个

你说过你有一个datarelation,我希望使用setdatabinding绑定维护
到数据集。在我看来,你可以做的事情如下:

\\\
Dim frm As New Form2
frm.DataGrid1.SetDataBinding(ds,_
" Maintable.DatarelationName")
frm.ShowDialog()
///

我希望这有帮助吗?
Cor
Hi Mad,

I was busy telling you the same as William did about the multipost, there is no problem when you crosspost (send one message to more newsgroups) than
others can see if the answer you did get in the adonet group was right for
you.

Because I was busy and with another approach than William I send this also.
You said you had a made a datarelation and I hope binded the maintable using setdatabinding to the dataset. Than you can do in my opinion something as:

\\\
Dim frm As New Form2
frm.DataGrid1.SetDataBinding(ds, _
"Maintable.DatarelationName")
frm.ShowDialog()
///

I hope this helps?
Cor



这篇关于认为应该是简单的但是很难找到信息:(的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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