抱歉重新发布 - 数据绑定问题 [英] Sorry to Re-Post - Databindings problem

查看:89
本文介绍了抱歉重新发布 - 数据绑定问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hey Group,


很抱歉,我一直在寻找这个甚至出去买了一本

ADO书,但仍然找不到我正在寻找:(


我的代码改为以下代码:


Private Sub objdsAccess_PositionChanged()

如果Me.BindingContext(objdsAccess," Users")。Position<> -1则

Me.ComboBox1.SelectedValue =

objdsAccess.Users。行(Me.BindingContext(objdsAcce ss,

" Users"。)。Position).Item(" AccessLevelID")

结束如果

Me.lblNavLocation.Text =(((Me.BindingContext(objdsAccess,

" Users")。Position + 1).ToString +" of)+ Me.BindingContext(objdsAccess,

" Users")。Count.ToString)

End Sub


这个工作正常,我的组合框。我的ComboBox使用以下代码:


Private Sub ComboBox1_SelectedIndexChanged(ByVal sender A s Object,ByVal e

As System.EventArgs)处理ComboBox1.SelectedIndexChanged

如果Me.BindingContext(objdsAccess," Users")。Position<> -1而不是

mlLoading然后

objdsAccess.Users.Rows(Me.BindingContext(objdsAcce ss,

" Users")。 ).Item(" AccessLevelID")= Me.ComboBox1.SelectedValue

结束如果

结束子


这一切都有效很好,如果我使用导航按钮并调用:

Me.objdsAccess_PositionChanged()。


但是我现在已经添加了一个Datagrid到我的表单,因为我在我的表单中选择一行。

如何更新我的ComboBox,并注意位置已更改?


谢谢

MCN

Hey Group,

Sorry but i`ve been searching everywhere for this even went out and bought a
ADO book and still carn`t find what im looking for:(

I have the following code for my postion changed:

Private Sub objdsAccess_PositionChanged()
If Me.BindingContext(objdsAccess, "Users").Position <> -1 Then
Me.ComboBox1.SelectedValue =
objdsAccess.Users.Rows(Me.BindingContext(objdsAcce ss,
"Users").Position).Item("AccessLevelID")
End If
Me.lblNavLocation.Text = (((Me.BindingContext(objdsAccess,
"Users").Position + 1).ToString + " of ") + Me.BindingContext(objdsAccess,
"Users").Count.ToString)
End Sub

This works fine, with my Combo Box. My ComboBox is using the following code:

Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As Object, ByVal e
As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
If Me.BindingContext(objdsAccess, "Users").Position <> -1 And Not
mlLoading Then
objdsAccess.Users.Rows(Me.BindingContext(objdsAcce ss,
"Users").Position).Item("AccessLevelID") = Me.ComboBox1.SelectedValue
End If
End Sub

This all works fine, if im using Navigation buttons and calling:
Me.objdsAccess_PositionChanged().

However I`ve now added a Datagrid to my Form, as I select a Row in my form.
How would i get it to update my ComboBox, and notice the position changed?

Thanks
MCN

推荐答案

如果他们与同一货币经理相关联,它将自动执行



然而,可能并非如此。无论如何,在ADO.NET中你有这些叫做CurrencyManagers的东西,它们基本上就像一个旧的

ADODB.Recordset(就像.NET中的许多东西一样)。无论如何,CurrencyManagers

是通过绑定创建的(实际上你是从

控件的bindingContext获得它们的。)


这个CurrencyManager自动订阅datagrid事件(或者

反之亦然,无论哪种方式,更改数据网格中的位置(即移动

到新行)货币经理的位置为你和一个活动改变了

被解雇了。


因此最好的处理方法是。


在你的课程中,你可以这样做...


私人WithEvents _cmMyDataset作为CurrencyManager


然后在你的表格载入中(我认为最好的地方,你可以做其他人,比如

你的构造函数,但并不是什么大不了的事。


_cmMyDataSet = BindingContext(myDataSource," myDataTable")


显然用数据集和数据表的有效值替换那些。


然后,在左上角的属性浏览器中(t他下降了你可以找到

变量_cmMyDataSet变量以及

右边与之关联的事件。


订阅到PositionChanged事件,然后你就可以做任何你想要的事情。 (即你的组合框基于新的行数据的东西)。


CurrencyMangers在进行记录操作时也非常有用,

因为你实际上可以关闭使用.SuspendBinding()

和.ResumeBinding()方法进行绑定,因此如果您使用大型列表(即填充大型数据集的
),则可以使用suspendbinding填写它

(否则,每次添加一个项目都会经过

重新绘制一个控件的过程,因为IListSource上的ListChanged事件

item。


HTH,

CJ


" MadCrazyNewbie"< te ** @ nospam .com>在留言中写道

新闻:yG ******************** @ karoo.co.uk ...
If they are associated with the same currency manager it will do it
automatically.

However, the probably isn''t the case. anyways, in ADO.NET you have these
things called CurrencyManagers that basically act kinda like an old
ADODB.Recordset (yes like many things in .NET). Anyways, CurrencyManagers
are created from bindings (actually you get them from the bindingContext of
the control).

This CurrencyManager is automatically subscribed the the datagrid events (or
vise versa, either way, upon changing the position in a datagrid (i.e moving
to a new row) the currency managers position is changed for you and an event
is fired.

so the best way to handle this is.

In your class delcaration do this...

Private WithEvents _cmMyDataset as CurrencyManager

Then in your form load (best place I think, you can do it others like in
your constructor, but not really a big deal.

_cmMyDataSet = BindingContext(myDataSource, "myDataTable")

Obviously replace those with valid values for your dataset and datatable.

Then, in your property browser on the top left (the drop down) you can find
the variable _cmMyDataSet Variable and the events associated with it on the
right.

Subscribe to the PositionChanged event, and then you can do whatever you
want. (i.e something with your combobox based on new row data).

CurrencyMangers are also INCREDIBLY useful when doing record manipulation,
because you can actually turn off the binding using the .SuspendBinding()
and .ResumeBinding() methods, so if your working with large lists (i.e.
filling a large dataset) you can use suspendbinding while your filling it
(otherwise, every time an item is added it goes through the process of
repainting a control because of the ListChanged event on an IListSource
item.

HTH,
CJ

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

抱歉,我一直在寻找这个甚至出去买了
a ADO书,但仍然找不到我正在寻找的东西:(

我的po有以下代码改变了:

Private Sub objdsAccess_PositionChanged()
如果Me.BindingContext(objdsAccess," Users")。Position<> -1然后
Me.ComboBox1.SelectedValue =
objdsAccess.Users.Rows(Me.BindingContext(objdsAcce ss,
" Users"。)。Position).Item(" AccessLevelID")
结束如果
Me.lblNavLocation.Text =(((Me.BindingContext(objdsAccess,
" Users")。Position + 1).ToString +" of)+
Me.BindingContext(objdsAccess," Users")。Count.ToString)
End Sub

这个工作正常,我的组合框。我的ComboBox使用以下
代码:
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As Object,ByVal e
As System.EventArgs)处理ComboBox1.SelectedIndexChanged
如果Me.BindingContext(objdsAccess) ,用户)。位置<> -1而不是
mlLoading然后
objdsAccess.Users.Rows(Me.BindingContext(objdsAcce ss,
" Users"。)。Position).Item(" AccessLevelID")= Me。 ComboBox1.SelectedValue
结束如果
结束子

这一切正常,如果我使用导航按钮并调用:
Me.objdsAccess_PositionChanged()。

但是我现在已经在我的表单中添加了一个Datagrid,因为我在
表单中选择了一行。如何更新我的ComboBox,并注意位置发生变化?

MCN
Hey Group,

Sorry but i`ve been searching everywhere for this even went out and bought a ADO book and still carn`t find what im looking for:(

I have the following code for my postion changed:

Private Sub objdsAccess_PositionChanged()
If Me.BindingContext(objdsAccess, "Users").Position <> -1 Then
Me.ComboBox1.SelectedValue =
objdsAccess.Users.Rows(Me.BindingContext(objdsAcce ss,
"Users").Position).Item("AccessLevelID")
End If
Me.lblNavLocation.Text = (((Me.BindingContext(objdsAccess,
"Users").Position + 1).ToString + " of ") + Me.BindingContext(objdsAccess, "Users").Count.ToString)
End Sub

This works fine, with my Combo Box. My ComboBox is using the following code:
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As Object, ByVal e
As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
If Me.BindingContext(objdsAccess, "Users").Position <> -1 And Not
mlLoading Then
objdsAccess.Users.Rows(Me.BindingContext(objdsAcce ss,
"Users").Position).Item("AccessLevelID") = Me.ComboBox1.SelectedValue
End If
End Sub

This all works fine, if im using Navigation buttons and calling:
Me.objdsAccess_PositionChanged().

However I`ve now added a Datagrid to my Form, as I select a Row in my form. How would i get it to update my ComboBox, and notice the position changed?

Thanks
MCN



嘿CJ,


你在做什么?


我已经添加了Private WithEvents cmDsAccess作为我的货币管理器

Class Decleration然后在我的表单加载中添加了cmDsAccess = BindingContext(objdsAccess,

" Users")
我现在怎么样?它改变我的文本框上的绑定,组合框

,因为我选择了我的数据网格中的行?


ManyThanks

MCN (Si)


通过Datasource,你的意思是

CJ Taylor <无**** @ blowgoats.com>在消息中写道

news:10 ************* @ corp.supernews.com ...
Hey CJ,

Hows you doing?

Right i`ve added Private WithEvents cmDsAccess As CurrencyManager in my
Class Decleration and then added cmDsAccess = BindingContext(objdsAccess,
"Users") in my form load.

How would i now get it to change my bindings on my textboxs, and Combo box
as i select rows in my Datagrid?

ManyThanks
MCN(Si)

By Datasource, do you mean the
"CJ Taylor" <no****@blowgoats.com> wrote in message
news:10*************@corp.supernews.com...
如果他们与相同的货币经理会自动完成它。

然而,情况可能并非如此。无论如何,在ADO.NET中你有这些名为CurrencyManagers的东西,它们基本上就像一个旧的ADODB.Recordset(就像.NET中的许多东西一样)。无论如何,CurrencyManagers
是通过绑定创建的(实际上你是从控件的bindingContext
得到的)。

这个CurrencyManager会自动订阅datagrid事件
(或者相反,无论哪种方式,在更改数据网格中的位置(即
移动到新行)时,货币经理的位置都会为您更改,并且会触发
事件。

在你的课程中,你可以这样做...

私人WithEvents _cmMyDataset作为CurrencyManager

然后在你的表单加载(最好的地方,我认为,你可以做其他像你的构造函数,但不是真的很大。

_cmMyDataSet = BindingContext(myDataSource," myDataTable")

显然用数据集和数据表的有效值替换那些。

然后,在左上角的属性浏览器(下拉列表)中,你可以
找到变量_cmMyDataSet变量和事件与
相关联的权利。

订阅PositionChanged事件,然后你可以做你想要的任何事情。 (即基于新行数据的组合框的东西)。

在进行记录操作时,CurrencyManger也非常有用,因为你实际上可以使用.SuspendBinding()来关闭绑定br />和.ResumeBinding()方法,所以如果您使用大型列表(即填充大型数据集),您可以在填充时使用suspendbinding
(否则,每次添加一个项目时)由于IListSource
项目上的ListChanged事件,因此重新完成了重新绘制控件的过程。

HTH,
CJ


MadCrazyNewbie< te ** @ nospam.com>在消息中写道
新闻:yG ******************** @ karoo。 co.uk ...
If they are associated with the same currency manager it will do it
automatically.

However, the probably isn''t the case. anyways, in ADO.NET you have these
things called CurrencyManagers that basically act kinda like an old
ADODB.Recordset (yes like many things in .NET). Anyways, CurrencyManagers
are created from bindings (actually you get them from the bindingContext of the control).

This CurrencyManager is automatically subscribed the the datagrid events (or vise versa, either way, upon changing the position in a datagrid (i.e moving to a new row) the currency managers position is changed for you and an event is fired.

so the best way to handle this is.

In your class delcaration do this...

Private WithEvents _cmMyDataset as CurrencyManager

Then in your form load (best place I think, you can do it others like in
your constructor, but not really a big deal.

_cmMyDataSet = BindingContext(myDataSource, "myDataTable")

Obviously replace those with valid values for your dataset and datatable.

Then, in your property browser on the top left (the drop down) you can find the variable _cmMyDataSet Variable and the events associated with it on the right.

Subscribe to the PositionChanged event, and then you can do whatever you
want. (i.e something with your combobox based on new row data).

CurrencyMangers are also INCREDIBLY useful when doing record manipulation,
because you can actually turn off the binding using the .SuspendBinding()
and .ResumeBinding() methods, so if your working with large lists (i.e.
filling a large dataset) you can use suspendbinding while your filling it
(otherwise, every time an item is added it goes through the process of
repainting a control because of the ListChanged event on an IListSource
item.

HTH,
CJ

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

很抱歉,我一直在寻找这个甚至出去了,
买了
Hey Group,

Sorry but i`ve been searching everywhere for this even went out and bought
一个
ADO书,仍然可以找到我正在寻找的东西:(

我有以下c我的位置的ode已更改:

Private Sub objdsAccess_PositionChanged()
如果Me.BindingContext(objdsAccess," Users")。Position<> -1然后
Me.ComboBox1.SelectedValue =
objdsAccess.Users.Rows(Me.BindingContext(objdsAcce ss,
" Users"。)。Position).Item(" AccessLevelID")
结束如果
Me.lblNavLocation.Text =(((Me.BindingContext(objdsAccess,
" Users")。Position + 1).ToString +" of of)+
ADO book and still carn`t find what im looking for:(

I have the following code for my postion changed:

Private Sub objdsAccess_PositionChanged()
If Me.BindingContext(objdsAccess, "Users").Position <> -1 Then
Me.ComboBox1.SelectedValue =
objdsAccess.Users.Rows(Me.BindingContext(objdsAcce ss,
"Users").Position).Item("AccessLevelID")
End If
Me.lblNavLocation.Text = (((Me.BindingContext(objdsAccess,
"Users").Position + 1).ToString + " of ") +


Me.BindingContext(objdsAccess,


Me.BindingContext(objdsAccess,

" Users")。Count.ToString)
End Sub

这很好用,我的组合框。我的ComboBox使用以下
"Users").Count.ToString)
End Sub

This works fine, with my Combo Box. My ComboBox is using the following


代码:


Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As Object,ByVal

Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As Object, ByVal


$ b $ as As System.EventArgs)处理ComboBox1.SelectedIndexChanged
如果Me.BindingContext(objdsAccess," Users")。Position<> -1而不是
mlLoading然后
objdsAccess.Users.Rows(Me.BindingContext(objdsAcce ss,
" Users"。)。Position).Item(" AccessLevelID")= Me。 ComboBox1.SelectedValue
结束如果
结束子

这一切正常,如果我使用导航按钮并调用:
Me.objdsAccess_PositionChanged()。

但是我现在已经在我的表单中添加了一个Datagrid,因为我在


e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
If Me.BindingContext(objdsAccess, "Users").Position <> -1 And Not
mlLoading Then
objdsAccess.Users.Rows(Me.BindingContext(objdsAcce ss,
"Users").Position).Item("AccessLevelID") = Me.ComboBox1.SelectedValue
End If
End Sub

This all works fine, if im using Navigation buttons and calling:
Me.objdsAccess_PositionChanged().

However I`ve now added a Datagrid to my Form, as I select a Row in my


表单中选择了一行。


form.

如何更新我的ComboBox ,并注意位置
的变化?
谢谢
MCN
How would i get it to update my ComboBox, and notice the position changed?
Thanks
MCN




< blockquote> Simon,


因为你宣布你的cmDsAccess WithEvents你可以在顶部

左下拉列表中查找它所描述的所有对象等(如文本框和所以

on。


在那里你会看到你的cmDsAccess对象。如果你点击它,你会看到
看到右侧组合框中的事件。其中一个将是定位

更改。


点击它(订阅它)然后那是你的通知

位置在您的数据网格中已更改。那时,无论你想要什么,你都可以做到
。例如,在你的头寸交易事件中你可以获得

来自货币管理器的当前行(cmDsAccess.Current())和

maniuplate你的组合框基于此。


怎么样?事情很忙,因为这些事情很糟糕。


=)

-CJ


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

新闻:Dc ******************** @ karoo.co.uk ...


嘿CJ,

你在做什么?

我已经在我的
Class Decleration中添加了Private WithEvents cmDsAccess作为CurrencyManager,然后添加了cmDsAccess = BindingContext(objdsAccess)在我的表单加载中,
用户。

我现在如何在我的文本框和组合框中更改我的绑定
,因为我选择了我的行Datagrid?

很多感谢MCN(Si)

数据源,你的意思是CJ泰勒吗? <无**** @ blowgoats.com>在消息中写道
新闻:10 ************* @ corp.supernews.com ...
Simon,

since you declared your cmDsAccess WithEvents you can look up in the top
left dropdown where it describes all you objects etc (like textboxes and so
on).

in there you will see your cmDsAccess object. If you click on it, you''ll
see the events on the right side combo box. One of those will be position
changed.

click it (subscribing to it) and then that is your notifcation that the row
position has changed within your datagrid. At that point, you can do
whatever you want. for exmaple, on your position chaged event you can get
the current row from the currency manager (cmDsAccess.Current()) and
maniuplate your combo boxes based off that.

How are things? Things are busy as sh**

=)

-CJ

"MadCrazyNewbie" <te**@nospam.com> wrote in message
news:Dc********************@karoo.co.uk...
如果他们与同一货币经理联系在一起会自动完成它。

然而,情况可能并非如此。无论如何,在ADO.NET中你有
这些
Hey CJ,

Hows you doing?

Right i`ve added Private WithEvents cmDsAccess As CurrencyManager in my
Class Decleration and then added cmDsAccess = BindingContext(objdsAccess,
"Users") in my form load.

How would i now get it to change my bindings on my textboxs, and Combo box
as i select rows in my Datagrid?

ManyThanks
MCN(Si)

By Datasource, do you mean the
"CJ Taylor" <no****@blowgoats.com> wrote in message
news:10*************@corp.supernews.com...
称为CurrencyManagers的东西基本上就像旧的一样
ADODB.Recordset(是的很多很多.NET中的东西)。无论如何,
CurrencyManagers是通过绑定创建的(实际上你是从
control的bindingContext中得到它们的。

这个CurrencyManager会自动订阅datagrid事件
things called CurrencyManagers that basically act kinda like an old
ADODB.Recordset (yes like many things in .NET). Anyways, CurrencyManagers are created from bindings (actually you get them from the bindingContext of


(或

反之亦然,无论如何,在更改数据网格中的位置时(即


(or


移动

到一个新的行)货币经理的位置已经改变了,并且


moving


事件

被解雇了。

所以处理这个的最好方法是。

在你的课程中,你可以这样做...

私人WithEvents _cmMyDataset作为CurrencyManager

然后在你的表单载入中(我认为最好的地方,你可以做其他人,比如你的构造函数,但不是很重要。

_cmMyDataSet = BindingContext(myDataSource," myDataTable")

显然更换那些具有有效值的da taset和
datatable。
然后,在你左边的属性浏览器(下拉列表)中你可以


event

找到

变量_cmMyDataSet变量


find

上的事件


正确。

订阅PositionChanged事件,然后你可以做任何你做的事情。 >想要。 (即基于新行数据的组合框的内容)。

在执行记录
操作时,CurrencyManger也非常有用,因为您实际上可以使用
关闭绑定。 .SuspendBinding()和.ResumeBinding()方法,所以如果你使用大型列表(即填充大型数据集),你可以在填充
时使用suspendbinding(否则,每次添加一个项目)由于IListSource
项目上的ListChanged事件,它经历了重新绘制控件的过程。

HTH,
CJ


" MadCrazyNewbie" te ** @ nospam.com>在消息中写道
新闻:yG ******************** @ karoo .co.uk ...
right.

Subscribe to the PositionChanged event, and then you can do whatever you
want. (i.e something with your combobox based on new row data).

CurrencyMangers are also INCREDIBLY useful when doing record manipulation, because you can actually turn off the binding using the ..SuspendBinding() and .ResumeBinding() methods, so if your working with large lists (i.e.
filling a large dataset) you can use suspendbinding while your filling it (otherwise, every time an item is added it goes through the process of
repainting a control because of the ListChanged event on an IListSource
item.

HTH,
CJ

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

抱歉,我一直在寻找这个甚至出去了
Hey Group,

Sorry but i`ve been searching everywhere for this even went out and


买了

一个
ADO书,仍然可以找到我正在寻找的东西:(

Private Sub objdsAccess_PositionChanged()
如果Me.BindingContext(objdsAccess," Users")。Position<> -1然后
Me.ComboBox1.SelectedValue =
objdsAccess.Users.Rows(Me.BindingContext(objdsAcce ss,
" Users"。)。Position).Item(" AccessLevelID")
结束如果
Me.lblNavLocation.Text =(((Me.BindingContext(objdsAccess,
" Users")。Position + 1).ToString +" of of)+
ADO book and still carn`t find what im looking for:(

I have the following code for my postion changed:

Private Sub objdsAccess_PositionChanged()
If Me.BindingContext(objdsAccess, "Users").Position <> -1 Then
Me.ComboBox1.SelectedValue =
objdsAccess.Users.Rows(Me.BindingContext(objdsAcce ss,
"Users").Position).Item("AccessLevelID")
End If
Me.lblNavLocation.Text = (((Me.BindingContext(objdsAccess,
"Users").Position + 1).ToString + " of ") +


Me.BindingContext(objdsAccess,


Me.BindingContext(objdsAccess,

" Users")。Count.ToString)
End Sub

这很好用,我的组合框。我的ComboBox使用以下
"Users").Count.ToString)
End Sub

This works fine, with my Combo Box. My ComboBox is using the following


代码:


Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As Object,

Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As Object,



ByVal e As System.EventArgs)处理ComboBox1.SelectedIndexChanged
如果Me.BindingContext(objdsAccess," Users")。Position<> -1而不是
mlLoading然后
objdsAccess.Users.Rows(Me.BindingContext(objdsAcce ss,
" Users"。)。Position).Item(" AccessLevelID")= Me。 ComboBox1.SelectedValue
结束如果
结束子

这一切正常,如果我使用导航按钮并调用:
Me.objdsAccess_PositionChanged()。

但是我现在已经在我的表单中添加了一个Datagrid,因为我在


ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
If Me.BindingContext(objdsAccess, "Users").Position <> -1 And Not
mlLoading Then
objdsAccess.Users.Rows(Me.BindingContext(objdsAcce ss,
"Users").Position).Item("AccessLevelID") = Me.ComboBox1.SelectedValue
End If
End Sub

This all works fine, if im using Navigation buttons and calling:
Me.objdsAccess_PositionChanged().

However I`ve now added a Datagrid to my Form, as I select a Row in my


表单中选择了一行。


form.

如何更新我的ComboBox ,并注意到位置发生了变化?
谢谢
MCN
How would i get it to update my ComboBox, and notice the position changed?
Thanks
MCN





这篇关于抱歉重新发布 - 数据绑定问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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