Connecting Tech Pros Worldwide Forums | Help | Site Map

Sorry to Re-Post - Databindings problem

MadCrazyNewbie
Guest
 
Posts: n/a
#1: Nov 20 '05
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 Taylor
Guest
 
Posts: n/a
#2: Nov 20 '05

re: Sorry to Re-Post - Databindings problem


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" <test@nospam.com> wrote in message
news:yG-dnSL3u-n8fvbdSa8jmw@karoo.co.uk...[color=blue]
> Hey Group,
>
> Sorry but i`ve been searching everywhere for this even went out and bought[/color]
a[color=blue]
> 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 ") +[/color]
Me.BindingContext(objdsAccess,[color=blue]
> "Users").Count.ToString)
> End Sub
>
> This works fine, with my Combo Box. My ComboBox is using the following[/color]
code:[color=blue]
>
> 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[/color]
form.[color=blue]
> How would i get it to update my ComboBox, and notice the position changed?
>
> Thanks
> MCN
>
>[/color]


MadCrazyNewbie
Guest
 
Posts: n/a
#3: Nov 20 '05

re: Sorry to Re-Post - Databindings problem


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" <nospam@blowgoats.com> wrote in message
news:106o5vusiej5m11@corp.supernews.com...[color=blue]
> 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[/color]
of[color=blue]
> the control).
>
> This CurrencyManager is automatically subscribed the the datagrid events[/color]
(or[color=blue]
> vise versa, either way, upon changing the position in a datagrid (i.e[/color]
moving[color=blue]
> to a new row) the currency managers position is changed for you and an[/color]
event[color=blue]
> 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[/color]
find[color=blue]
> the variable _cmMyDataSet Variable and the events associated with it on[/color]
the[color=blue]
> 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" <test@nospam.com> wrote in message
> news:yG-dnSL3u-n8fvbdSa8jmw@karoo.co.uk...[color=green]
> > Hey Group,
> >
> > Sorry but i`ve been searching everywhere for this even went out and[/color][/color]
bought[color=blue]
> a[color=green]
> > 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 ") +[/color]
> Me.BindingContext(objdsAccess,[color=green]
> > "Users").Count.ToString)
> > End Sub
> >
> > This works fine, with my Combo Box. My ComboBox is using the following[/color]
> code:[color=green]
> >
> > Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As Object, ByVal[/color][/color]
e[color=blue][color=green]
> > 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[/color]
> form.[color=green]
> > How would i get it to update my ComboBox, and notice the position[/color][/color]
changed?[color=blue][color=green]
> >
> > Thanks
> > MCN
> >
> >[/color]
>
>[/color]


CJ Taylor
Guest
 
Posts: n/a
#4: Nov 20 '05

re: Sorry to Re-Post - Databindings problem


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" <test@nospam.com> wrote in message
news:DcicnZCda82qv_HdSa8jmw@karoo.co.uk...[color=blue]
> 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" <nospam@blowgoats.com> wrote in message
> news:106o5vusiej5m11@corp.supernews.com...[color=green]
> > 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[/color][/color]
these[color=blue][color=green]
> > things called CurrencyManagers that basically act kinda like an old
> > ADODB.Recordset (yes like many things in .NET). Anyways,[/color][/color]
CurrencyManagers[color=blue][color=green]
> > are created from bindings (actually you get them from the bindingContext[/color]
> of[color=green]
> > the control).
> >
> > This CurrencyManager is automatically subscribed the the datagrid events[/color]
> (or[color=green]
> > vise versa, either way, upon changing the position in a datagrid (i.e[/color]
> moving[color=green]
> > to a new row) the currency managers position is changed for you and an[/color]
> event[color=green]
> > 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[/color][/color]
datatable.[color=blue][color=green]
> >
> > Then, in your property browser on the top left (the drop down) you can[/color]
> find[color=green]
> > the variable _cmMyDataSet Variable and the events associated with it on[/color]
> the[color=green]
> > 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[/color][/color]
manipulation,[color=blue][color=green]
> > because you can actually turn off the binding using the[/color][/color]
..SuspendBinding()[color=blue][color=green]
> > and .ResumeBinding() methods, so if your working with large lists (i.e.
> > filling a large dataset) you can use suspendbinding while your filling[/color][/color]
it[color=blue][color=green]
> > (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" <test@nospam.com> wrote in message
> > news:yG-dnSL3u-n8fvbdSa8jmw@karoo.co.uk...[color=darkred]
> > > Hey Group,
> > >
> > > Sorry but i`ve been searching everywhere for this even went out and[/color][/color]
> bought[color=green]
> > a[color=darkred]
> > > 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 ") +[/color]
> > Me.BindingContext(objdsAccess,[color=darkred]
> > > "Users").Count.ToString)
> > > End Sub
> > >
> > > This works fine, with my Combo Box. My ComboBox is using the following[/color]
> > code:[color=darkred]
> > >
> > > Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As Object,[/color][/color][/color]
ByVal[color=blue]
> e[color=green][color=darkred]
> > > 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[/color]
> > form.[color=darkred]
> > > How would i get it to update my ComboBox, and notice the position[/color][/color]
> changed?[color=green][color=darkred]
> > >
> > > Thanks
> > > MCN
> > >
> > >[/color]
> >
> >[/color]
>
>[/color]


MadCrazyNewbie
Guest
 
Posts: n/a
#5: Nov 20 '05

re: Sorry to Re-Post - Databindings problem


CJ

Im not to bad been really busy with work and wot not:( All work and no
play:(

Anyways ....... I`ve looked in my propery Browser but i carn`t seem to find
cmDsAccess anywhere in there:(

Any Ideas?

Ta
MCN(Si)

"CJ Taylor" <nospam@blowgoats.com> wrote in message
news:106oa42e5ir6349@corp.supernews.com...[color=blue]
> 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[/color]
so[color=blue]
> 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[/color]
row[color=blue]
> 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" <test@nospam.com> wrote in message
> news:DcicnZCda82qv_HdSa8jmw@karoo.co.uk...[color=green]
> > Hey CJ,
> >
> > Hows you doing?
> >
> > Right i`ve added Private WithEvents cmDsAccess As CurrencyManager in my
> > Class Decleration and then added cmDsAccess =[/color][/color]
BindingContext(objdsAccess,[color=blue][color=green]
> > "Users") in my form load.
> >
> > How would i now get it to change my bindings on my textboxs, and Combo[/color][/color]
box[color=blue][color=green]
> > as i select rows in my Datagrid?
> >
> > ManyThanks
> > MCN(Si)
> >
> > By Datasource, do you mean the
> > "CJ Taylor" <nospam@blowgoats.com> wrote in message
> > news:106o5vusiej5m11@corp.supernews.com...[color=darkred]
> > > 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[/color][/color]
> these[color=green][color=darkred]
> > > things called CurrencyManagers that basically act kinda like an old
> > > ADODB.Recordset (yes like many things in .NET). Anyways,[/color][/color]
> CurrencyManagers[color=green][color=darkred]
> > > are created from bindings (actually you get them from the[/color][/color][/color]
bindingContext[color=blue][color=green]
> > of[color=darkred]
> > > the control).
> > >
> > > This CurrencyManager is automatically subscribed the the datagrid[/color][/color][/color]
events[color=blue][color=green]
> > (or[color=darkred]
> > > vise versa, either way, upon changing the position in a datagrid (i.e[/color]
> > moving[color=darkred]
> > > to a new row) the currency managers position is changed for you and an[/color]
> > event[color=darkred]
> > > 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[/color][/color][/color]
in[color=blue][color=green][color=darkred]
> > > your constructor, but not really a big deal.
> > >
> > > _cmMyDataSet = BindingContext(myDataSource, "myDataTable")
> > >
> > > Obviously replace those with valid values for your dataset and[/color][/color]
> datatable.[color=green][color=darkred]
> > >
> > > Then, in your property browser on the top left (the drop down) you can[/color]
> > find[color=darkred]
> > > the variable _cmMyDataSet Variable and the events associated with it[/color][/color][/color]
on[color=blue][color=green]
> > the[color=darkred]
> > > right.
> > >
> > > Subscribe to the PositionChanged event, and then you can do whatever[/color][/color][/color]
you[color=blue][color=green][color=darkred]
> > > want. (i.e something with your combobox based on new row data).
> > >
> > > CurrencyMangers are also INCREDIBLY useful when doing record[/color][/color]
> manipulation,[color=green][color=darkred]
> > > because you can actually turn off the binding using the[/color][/color]
> .SuspendBinding()[color=green][color=darkred]
> > > and .ResumeBinding() methods, so if your working with large lists[/color][/color][/color]
(i.e.[color=blue][color=green][color=darkred]
> > > filling a large dataset) you can use suspendbinding while your filling[/color][/color]
> it[color=green][color=darkred]
> > > (otherwise, every time an item is added it goes through the process of
> > > repainting a control because of the ListChanged event on an[/color][/color][/color]
IListSource[color=blue][color=green][color=darkred]
> > > item.
> > >
> > > HTH,
> > > CJ
> > >
> > >
> > >
> > >
> > >
> > > "MadCrazyNewbie" <test@nospam.com> wrote in message
> > > news:yG-dnSL3u-n8fvbdSa8jmw@karoo.co.uk...
> > > > Hey Group,
> > > >
> > > > Sorry but i`ve been searching everywhere for this even went out and[/color]
> > bought[color=darkred]
> > > 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[/color][/color][/color]
following[color=blue][color=green][color=darkred]
> > > code:
> > > >
> > > > Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As Object,[/color][/color]
> ByVal[color=green]
> > e[color=darkred]
> > > > As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
> > > > If Me.BindingContext(objdsAccess, "Users").Position <> -1 And[/color][/color][/color]
Not[color=blue][color=green][color=darkred]
> > > > mlLoading Then
> > > > objdsAccess.Users.Rows(Me.BindingContext(objdsAcce ss,
> > > > "Users").Position).Item("AccessLevelID") =[/color][/color][/color]
Me.ComboBox1.SelectedValue[color=blue][color=green][color=darkred]
> > > > 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[/color][/color][/color]
my[color=blue][color=green][color=darkred]
> > > form.
> > > > How would i get it to update my ComboBox, and notice the position[/color]
> > changed?[color=darkred]
> > > >
> > > > Thanks
> > > > MCN
> > > >
> > > >
> > >
> > >[/color]
> >
> >[/color]
>
>[/color]


CJ Taylor
Guest
 
Posts: n/a
#6: Nov 20 '05

re: Sorry to Re-Post - Databindings problem


Go to your Code Window... Look at the combo box on the top left side.. you
can't miss it.. there are two of them. right above your code. look there.
=)




"MadCrazyNewbie" <test@nospam.com> wrote in message
news:iv-cnWPk1byYsfHdSa8jmw@karoo.co.uk...[color=blue]
> CJ
>
> Im not to bad been really busy with work and wot not:( All work and no
> play:(
>
> Anyways ....... I`ve looked in my propery Browser but i carn`t seem to[/color]
find[color=blue]
> cmDsAccess anywhere in there:(
>
> Any Ideas?
>
> Ta
> MCN(Si)
>
> "CJ Taylor" <nospam@blowgoats.com> wrote in message
> news:106oa42e5ir6349@corp.supernews.com...[color=green]
> > 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[/color]
> so[color=green]
> > on).
> >
> > in there you will see your cmDsAccess object. If you click on it,[/color][/color]
you'll[color=blue][color=green]
> > see the events on the right side combo box. One of those will be[/color][/color]
position[color=blue][color=green]
> > changed.
> >
> > click it (subscribing to it) and then that is your notifcation that the[/color]
> row[color=green]
> > position has changed within your datagrid. At that point, you can do
> > whatever you want. for exmaple, on your position chaged event you can[/color][/color]
get[color=blue][color=green]
> > 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" <test@nospam.com> wrote in message
> > news:DcicnZCda82qv_HdSa8jmw@karoo.co.uk...[color=darkred]
> > > Hey CJ,
> > >
> > > Hows you doing?
> > >
> > > Right i`ve added Private WithEvents cmDsAccess As CurrencyManager in[/color][/color][/color]
my[color=blue][color=green][color=darkred]
> > > Class Decleration and then added cmDsAccess =[/color][/color]
> BindingContext(objdsAccess,[color=green][color=darkred]
> > > "Users") in my form load.
> > >
> > > How would i now get it to change my bindings on my textboxs, and Combo[/color][/color]
> box[color=green][color=darkred]
> > > as i select rows in my Datagrid?
> > >
> > > ManyThanks
> > > MCN(Si)
> > >
> > > By Datasource, do you mean the
> > > "CJ Taylor" <nospam@blowgoats.com> wrote in message
> > > news:106o5vusiej5m11@corp.supernews.com...
> > > > 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[/color]
> > these[color=darkred]
> > > > things called CurrencyManagers that basically act kinda like an old
> > > > ADODB.Recordset (yes like many things in .NET). Anyways,[/color]
> > CurrencyManagers[color=darkred]
> > > > are created from bindings (actually you get them from the[/color][/color]
> bindingContext[color=green][color=darkred]
> > > of
> > > > the control).
> > > >
> > > > This CurrencyManager is automatically subscribed the the datagrid[/color][/color]
> events[color=green][color=darkred]
> > > (or
> > > > vise versa, either way, upon changing the position in a datagrid[/color][/color][/color]
(i.e[color=blue][color=green][color=darkred]
> > > moving
> > > > to a new row) the currency managers position is changed for you and[/color][/color][/color]
an[color=blue][color=green][color=darkred]
> > > 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[/color][/color][/color]
like[color=blue]
> in[color=green][color=darkred]
> > > > your constructor, but not really a big deal.
> > > >
> > > > _cmMyDataSet = BindingContext(myDataSource, "myDataTable")
> > > >
> > > > Obviously replace those with valid values for your dataset and[/color]
> > datatable.[color=darkred]
> > > >
> > > > Then, in your property browser on the top left (the drop down) you[/color][/color][/color]
can[color=blue][color=green][color=darkred]
> > > find
> > > > the variable _cmMyDataSet Variable and the events associated with it[/color][/color]
> on[color=green][color=darkred]
> > > the
> > > > right.
> > > >
> > > > Subscribe to the PositionChanged event, and then you can do whatever[/color][/color]
> you[color=green][color=darkred]
> > > > want. (i.e something with your combobox based on new row data).
> > > >
> > > > CurrencyMangers are also INCREDIBLY useful when doing record[/color]
> > manipulation,[color=darkred]
> > > > because you can actually turn off the binding using the[/color]
> > .SuspendBinding()[color=darkred]
> > > > and .ResumeBinding() methods, so if your working with large lists[/color][/color]
> (i.e.[color=green][color=darkred]
> > > > filling a large dataset) you can use suspendbinding while your[/color][/color][/color]
filling[color=blue][color=green]
> > it[color=darkred]
> > > > (otherwise, every time an item is added it goes through the process[/color][/color][/color]
of[color=blue][color=green][color=darkred]
> > > > repainting a control because of the ListChanged event on an[/color][/color]
> IListSource[color=green][color=darkred]
> > > > item.
> > > >
> > > > HTH,
> > > > CJ
> > > >
> > > >
> > > >
> > > >
> > > >
> > > > "MadCrazyNewbie" <test@nospam.com> wrote in message
> > > > news:yG-dnSL3u-n8fvbdSa8jmw@karoo.co.uk...
> > > > > Hey Group,
> > > > >
> > > > > Sorry but i`ve been searching everywhere for this even went out[/color][/color][/color]
and[color=blue][color=green][color=darkred]
> > > 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[/color][/color]
> following[color=green][color=darkred]
> > > > code:
> > > > >
> > > > > Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As Object,[/color]
> > ByVal[color=darkred]
> > > e
> > > > > As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
> > > > > If Me.BindingContext(objdsAccess, "Users").Position <> -1 And[/color][/color]
> Not[color=green][color=darkred]
> > > > > mlLoading Then
> > > > > objdsAccess.Users.Rows(Me.BindingContext(objdsAcce ss,
> > > > > "Users").Position).Item("AccessLevelID") =[/color][/color]
> Me.ComboBox1.SelectedValue[color=green][color=darkred]
> > > > > 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[/color][/color]
> my[color=green][color=darkred]
> > > > form.
> > > > > How would i get it to update my ComboBox, and notice the position
> > > changed?
> > > > >
> > > > > Thanks
> > > > > MCN
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >[/color]
> >
> >[/color]
>
>[/color]


MadCrazyNewbie
Guest
 
Posts: n/a
#7: Nov 20 '05

re: Sorry to Re-Post - Databindings problem


Sorry CJ, I Must be going blind.

I think im going mad aswell and probably missing the point:(

How do i get it to do my positions changed? I have my Nav buttons setup to
call: Me.objDsAccess_PositionChanged.

My Position Change code is as follows:

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

How do i get this to work for my Datagrid. Do I need a:
Datagrid1_SelectedIndexChanged. Sorry i don`t know where to call a datgird
PostionChanged from or am I barking up the wrong tree?

Sorry to be a pain.

Cheers
MCN(Si)

"CJ Taylor" <nospam@blowgoats.com> wrote in message
news:106obctc5u2pc39@corp.supernews.com...[color=blue]
> Go to your Code Window... Look at the combo box on the top left side..[/color]
you[color=blue]
> can't miss it.. there are two of them. right above your code. look[/color]
there.[color=blue]
> =)
>
>
>
>
> "MadCrazyNewbie" <test@nospam.com> wrote in message
> news:iv-cnWPk1byYsfHdSa8jmw@karoo.co.uk...[color=green]
> > CJ
> >
> > Im not to bad been really busy with work and wot not:( All work and no
> > play:(
> >
> > Anyways ....... I`ve looked in my propery Browser but i carn`t seem to[/color]
> find[color=green]
> > cmDsAccess anywhere in there:(
> >
> > Any Ideas?
> >
> > Ta
> > MCN(Si)
> >
> > "CJ Taylor" <nospam@blowgoats.com> wrote in message
> > news:106oa42e5ir6349@corp.supernews.com...[color=darkred]
> > > Simon,
> > >
> > > since you declared your cmDsAccess WithEvents you can look up in the[/color][/color][/color]
top[color=blue][color=green][color=darkred]
> > > left dropdown where it describes all you objects etc (like textboxes[/color][/color][/color]
and[color=blue][color=green]
> > so[color=darkred]
> > > on).
> > >
> > > in there you will see your cmDsAccess object. If you click on it,[/color][/color]
> you'll[color=green][color=darkred]
> > > see the events on the right side combo box. One of those will be[/color][/color]
> position[color=green][color=darkred]
> > > changed.
> > >
> > > click it (subscribing to it) and then that is your notifcation that[/color][/color][/color]
the[color=blue][color=green]
> > row[color=darkred]
> > > position has changed within your datagrid. At that point, you can do
> > > whatever you want. for exmaple, on your position chaged event you can[/color][/color]
> get[color=green][color=darkred]
> > > 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" <test@nospam.com> wrote in message
> > > news:DcicnZCda82qv_HdSa8jmw@karoo.co.uk...
> > > > Hey CJ,
> > > >
> > > > Hows you doing?
> > > >
> > > > Right i`ve added Private WithEvents cmDsAccess As CurrencyManager in[/color][/color]
> my[color=green][color=darkred]
> > > > Class Decleration and then added cmDsAccess =[/color]
> > BindingContext(objdsAccess,[color=darkred]
> > > > "Users") in my form load.
> > > >
> > > > How would i now get it to change my bindings on my textboxs, and[/color][/color][/color]
Combo[color=blue][color=green]
> > box[color=darkred]
> > > > as i select rows in my Datagrid?
> > > >
> > > > ManyThanks
> > > > MCN(Si)
> > > >
> > > > By Datasource, do you mean the
> > > > "CJ Taylor" <nospam@blowgoats.com> wrote in message
> > > > news:106o5vusiej5m11@corp.supernews.com...
> > > > > If they are associated with the same currency manager it will do[/color][/color][/color]
it[color=blue][color=green][color=darkred]
> > > > > automatically.
> > > > >
> > > > > However, the probably isn't the case. anyways, in ADO.NET you[/color][/color][/color]
have[color=blue][color=green][color=darkred]
> > > these
> > > > > things called CurrencyManagers that basically act kinda like an[/color][/color][/color]
old[color=blue][color=green][color=darkred]
> > > > > ADODB.Recordset (yes like many things in .NET). Anyways,
> > > CurrencyManagers
> > > > > are created from bindings (actually you get them from the[/color]
> > bindingContext[color=darkred]
> > > > of
> > > > > the control).
> > > > >
> > > > > This CurrencyManager is automatically subscribed the the datagrid[/color]
> > events[color=darkred]
> > > > (or
> > > > > vise versa, either way, upon changing the position in a datagrid[/color][/color]
> (i.e[color=green][color=darkred]
> > > > moving
> > > > > to a new row) the currency managers position is changed for you[/color][/color][/color]
and[color=blue]
> an[color=green][color=darkred]
> > > > 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[/color][/color]
> like[color=green]
> > in[color=darkred]
> > > > > 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[/color][/color]
> can[color=green][color=darkred]
> > > > find
> > > > > the variable _cmMyDataSet Variable and the events associated with[/color][/color][/color]
it[color=blue][color=green]
> > on[color=darkred]
> > > > the
> > > > > right.
> > > > >
> > > > > Subscribe to the PositionChanged event, and then you can do[/color][/color][/color]
whatever[color=blue][color=green]
> > you[color=darkred]
> > > > > 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[/color]
> > (i.e.[color=darkred]
> > > > > filling a large dataset) you can use suspendbinding while your[/color][/color]
> filling[color=green][color=darkred]
> > > it
> > > > > (otherwise, every time an item is added it goes through the[/color][/color][/color]
process[color=blue]
> of[color=green][color=darkred]
> > > > > repainting a control because of the ListChanged event on an[/color]
> > IListSource[color=darkred]
> > > > > item.
> > > > >
> > > > > HTH,
> > > > > CJ
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > "MadCrazyNewbie" <test@nospam.com> wrote in message
> > > > > news:yG-dnSL3u-n8fvbdSa8jmw@karoo.co.uk...
> > > > > > Hey Group,
> > > > > >
> > > > > > Sorry but i`ve been searching everywhere for this even went out[/color][/color]
> and[color=green][color=darkred]
> > > > 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[/color][/color][/color]
Then[color=blue][color=green][color=darkred]
> > > > > > 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[/color]
> > following[color=darkred]
> > > > > code:
> > > > > >
> > > > > > Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As[/color][/color][/color]
Object,[color=blue][color=green][color=darkred]
> > > ByVal
> > > > e
> > > > > > As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
> > > > > > If Me.BindingContext(objdsAccess, "Users").Position <> -1[/color][/color][/color]
And[color=blue][color=green]
> > Not[color=darkred]
> > > > > > mlLoading Then
> > > > > > objdsAccess.Users.Rows(Me.BindingContext(objdsAcce ss,
> > > > > > "Users").Position).Item("AccessLevelID") =[/color]
> > Me.ComboBox1.SelectedValue[color=darkred]
> > > > > > 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[/color][/color][/color]
in[color=blue][color=green]
> > my[color=darkred]
> > > > > form.
> > > > > > How would i get it to update my ComboBox, and notice the[/color][/color][/color]
position[color=blue][color=green][color=darkred]
> > > > changed?
> > > > > >
> > > > > > Thanks
> > > > > > MCN
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >[/color]
> >
> >[/color]
>
>[/color]


CJ Taylor
Guest
 
Posts: n/a
#8: Nov 20 '05

re: Sorry to Re-Post - Databindings problem


Killin me dog.

Alright, lets back it up a little bit. =)

1) objdsAccess_PositionChanged()

How is this called? what causes this to be called.?



2) Me.BindingContext(objdsAccess, "Users").

that right there is a currency manager. you can assign a variable to it,
makes things easier. Is your datagrid bound to this datatable on the
objDsAccess? what table is it bound to?



"MadCrazyNewbie" <test@nospam.com> wrote in message
news:u7qcnXP5FrCprPHdSa8jmA@karoo.co.uk...[color=blue]
> Sorry CJ, I Must be going blind.
>
> I think im going mad aswell and probably missing the point:(
>
> How do i get it to do my positions changed? I have my Nav buttons setup to
> call: Me.objDsAccess_PositionChanged.
>
> My Position Change code is as follows:
>
> 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
>
> How do i get this to work for my Datagrid. Do I need a:
> Datagrid1_SelectedIndexChanged. Sorry i don`t know where to call a datgird
> PostionChanged from or am I barking up the wrong tree?
>
> Sorry to be a pain.
>
> Cheers
> MCN(Si)
>
> "CJ Taylor" <nospam@blowgoats.com> wrote in message
> news:106obctc5u2pc39@corp.supernews.com...[color=green]
> > Go to your Code Window... Look at the combo box on the top left side..[/color]
> you[color=green]
> > can't miss it.. there are two of them. right above your code. look[/color]
> there.[color=green]
> > =)
> >
> >
> >
> >
> > "MadCrazyNewbie" <test@nospam.com> wrote in message
> > news:iv-cnWPk1byYsfHdSa8jmw@karoo.co.uk...[color=darkred]
> > > CJ
> > >
> > > Im not to bad been really busy with work and wot not:( All work and no
> > > play:(
> > >
> > > Anyways ....... I`ve looked in my propery Browser but i carn`t seem to[/color]
> > find[color=darkred]
> > > cmDsAccess anywhere in there:(
> > >
> > > Any Ideas?
> > >
> > > Ta
> > > MCN(Si)
> > >
> > > "CJ Taylor" <nospam@blowgoats.com> wrote in message
> > > news:106oa42e5ir6349@corp.supernews.com...
> > > > Simon,
> > > >
> > > > since you declared your cmDsAccess WithEvents you can look up in the[/color][/color]
> top[color=green][color=darkred]
> > > > left dropdown where it describes all you objects etc (like textboxes[/color][/color]
> and[color=green][color=darkred]
> > > so
> > > > on).
> > > >
> > > > in there you will see your cmDsAccess object. If you click on it,[/color]
> > you'll[color=darkred]
> > > > see the events on the right side combo box. One of those will be[/color]
> > position[color=darkred]
> > > > changed.
> > > >
> > > > click it (subscribing to it) and then that is your notifcation that[/color][/color]
> the[color=green][color=darkred]
> > > row
> > > > position has changed within your datagrid. At that point, you can[/color][/color][/color]
do[color=blue][color=green][color=darkred]
> > > > whatever you want. for exmaple, on your position chaged event you[/color][/color][/color]
can[color=blue][color=green]
> > get[color=darkred]
> > > > 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" <test@nospam.com> wrote in message
> > > > news:DcicnZCda82qv_HdSa8jmw@karoo.co.uk...
> > > > > Hey CJ,
> > > > >
> > > > > Hows you doing?
> > > > >
> > > > > Right i`ve added Private WithEvents cmDsAccess As CurrencyManager[/color][/color][/color]
in[color=blue][color=green]
> > my[color=darkred]
> > > > > 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[/color][/color]
> Combo[color=green][color=darkred]
> > > box
> > > > > as i select rows in my Datagrid?
> > > > >
> > > > > ManyThanks
> > > > > MCN(Si)
> > > > >
> > > > > By Datasource, do you mean the
> > > > > "CJ Taylor" <nospam@blowgoats.com> wrote in message
> > > > > news:106o5vusiej5m11@corp.supernews.com...
> > > > > > If they are associated with the same currency manager it will do[/color][/color]
> it[color=green][color=darkred]
> > > > > > automatically.
> > > > > >
> > > > > > However, the probably isn't the case. anyways, in ADO.NET you[/color][/color]
> have[color=green][color=darkred]
> > > > these
> > > > > > things called CurrencyManagers that basically act kinda like an[/color][/color]
> old[color=green][color=darkred]
> > > > > > 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[/color][/color][/color]
datagrid[color=blue][color=green][color=darkred]
> > > events
> > > > > (or
> > > > > > vise versa, either way, upon changing the position in a datagrid[/color]
> > (i.e[color=darkred]
> > > > > moving
> > > > > > to a new row) the currency managers position is changed for you[/color][/color]
> and[color=green]
> > an[color=darkred]
> > > > > 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[/color]
> > like[color=darkred]
> > > 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)[/color][/color][/color]
you[color=blue][color=green]
> > can[color=darkred]
> > > > > find
> > > > > > the variable _cmMyDataSet Variable and the events associated[/color][/color][/color]
with[color=blue]
> it[color=green][color=darkred]
> > > on
> > > > > the
> > > > > > right.
> > > > > >
> > > > > > Subscribe to the PositionChanged event, and then you can do[/color][/color]
> whatever[color=green][color=darkred]
> > > 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[/color][/color][/color]
lists[color=blue][color=green][color=darkred]
> > > (i.e.
> > > > > > filling a large dataset) you can use suspendbinding while your[/color]
> > filling[color=darkred]
> > > > it
> > > > > > (otherwise, every time an item is added it goes through the[/color][/color]
> process[color=green]
> > of[color=darkred]
> > > > > > repainting a control because of the ListChanged event on an
> > > IListSource
> > > > > > item.
> > > > > >
> > > > > > HTH,
> > > > > > CJ
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > > "MadCrazyNewbie" <test@nospam.com> wrote in message
> > > > > > news:yG-dnSL3u-n8fvbdSa8jmw@karoo.co.uk...
> > > > > > > Hey Group,
> > > > > > >
> > > > > > > Sorry but i`ve been searching everywhere for this even went[/color][/color][/color]
out[color=blue][color=green]
> > and[color=darkred]
> > > > > 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[/color][/color]
> Then[color=green][color=darkred]
> > > > > > > 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[/color][/color]
> Object,[color=green][color=darkred]
> > > > ByVal
> > > > > e
> > > > > > > As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
> > > > > > > If Me.BindingContext(objdsAccess, "Users").Position <> -1[/color][/color]
> And[color=green][color=darkred]
> > > 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[/color][/color][/color]
calling:[color=blue][color=green][color=darkred]
> > > > > > > Me.objdsAccess_PositionChanged().
> > > > > > >
> > > > > > > However I`ve now added a Datagrid to my Form, as I select a[/color][/color][/color]
Row[color=blue]
> in[color=green][color=darkred]
> > > my
> > > > > > form.
> > > > > > > How would i get it to update my ComboBox, and notice the[/color][/color]
> position[color=green][color=darkred]
> > > > > changed?
> > > > > > >
> > > > > > > Thanks
> > > > > > > MCN
> > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >[/color]
> >
> >[/color]
>
>[/color]


MadCrazyNewbie
Guest
 
Posts: n/a
#9: Nov 20 '05

re: Sorry to Re-Post - Databindings problem


From my Nav buttons I call objDsAccess_PostitionChanged() for example:

Private Sub btnNavFirst_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnNavFirst.Click
Me.BindingContext(objdsAccess, "Users").Position = 0
Me.objdsAccess_PositionChanged()
End Sub

My Datatable is bound to objdsAccess.Users.

I have a relationship Setup from my Users Table, AccessID row to my
AccessLevel Table AccessID.

My AccessLevelID Table has a AccessLevel Feild in it to which my ComboBox
Looks at.

Ta
MCN(Si)

"CJ Taylor" <nospam@blowgoats.com> wrote in message
news:106ocj9bf90ct2c@corp.supernews.com...[color=blue]
> Killin me dog.
>
> Alright, lets back it up a little bit. =)
>
> 1) objdsAccess_PositionChanged()
>
> How is this called? what causes this to be called.?
>
>
>
> 2) Me.BindingContext(objdsAccess, "Users").
>
> that right there is a currency manager. you can assign a variable to it,
> makes things easier. Is your datagrid bound to this datatable on the
> objDsAccess? what table is it bound to?
>
>
>
> "MadCrazyNewbie" <test@nospam.com> wrote in message
> news:u7qcnXP5FrCprPHdSa8jmA@karoo.co.uk...[color=green]
> > Sorry CJ, I Must be going blind.
> >
> > I think im going mad aswell and probably missing the point:(
> >
> > How do i get it to do my positions changed? I have my Nav buttons setup[/color][/color]
to[color=blue][color=green]
> > call: Me.objDsAccess_PositionChanged.
> >
> > My Position Change code is as follows:
> >
> > 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 ") +[/color][/color]
Me.BindingContext(objdsAccess,[color=blue][color=green]
> > "Users").Count.ToString)
> > End Sub
> >
> > How do i get this to work for my Datagrid. Do I need a:
> > Datagrid1_SelectedIndexChanged. Sorry i don`t know where to call a[/color][/color]
datgird[color=blue][color=green]
> > PostionChanged from or am I barking up the wrong tree?
> >
> > Sorry to be a pain.
> >
> > Cheers
> > MCN(Si)
> >
> > "CJ Taylor" <nospam@blowgoats.com> wrote in message
> > news:106obctc5u2pc39@corp.supernews.com...[color=darkred]
> > > Go to your Code Window... Look at the combo box on the top left[/color][/color][/color]
side..[color=blue][color=green]
> > you[color=darkred]
> > > can't miss it.. there are two of them. right above your code. look[/color]
> > there.[color=darkred]
> > > =)
> > >
> > >
> > >
> > >
> > > "MadCrazyNewbie" <test@nospam.com> wrote in message
> > > news:iv-cnWPk1byYsfHdSa8jmw@karoo.co.uk...
> > > > CJ
> > > >
> > > > Im not to bad been really busy with work and wot not:( All work and[/color][/color][/color]
no[color=blue][color=green][color=darkred]
> > > > play:(
> > > >
> > > > Anyways ....... I`ve looked in my propery Browser but i carn`t seem[/color][/color][/color]
to[color=blue][color=green][color=darkred]
> > > find
> > > > cmDsAccess anywhere in there:(
> > > >
> > > > Any Ideas?
> > > >
> > > > Ta
> > > > MCN(Si)
> > > >
> > > > "CJ Taylor" <nospam@blowgoats.com> wrote in message
> > > > news:106oa42e5ir6349@corp.supernews.com...
> > > > > Simon,
> > > > >
> > > > > since you declared your cmDsAccess WithEvents you can look up in[/color][/color][/color]
the[color=blue][color=green]
> > top[color=darkred]
> > > > > left dropdown where it describes all you objects etc (like[/color][/color][/color]
textboxes[color=blue][color=green]
> > and[color=darkred]
> > > > 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[/color][/color][/color]
that[color=blue][color=green]
> > the[color=darkred]
> > > > row
> > > > > position has changed within your datagrid. At that point, you can[/color][/color]
> do[color=green][color=darkred]
> > > > > whatever you want. for exmaple, on your position chaged event you[/color][/color]
> can[color=green][color=darkred]
> > > get
> > > > > the current row from the currency manager (cmDsAccess.Current())[/color][/color][/color]
and[color=blue][color=green][color=darkred]
> > > > > maniuplate your combo boxes based off that.
> > > > >
> > > > > How are things? Things are busy as sh**
> > > > >
> > > > > =)
> > > > >
> > > > > -CJ
> > > > >
> > > > > "MadCrazyNewbie" <test@nospam.com> wrote in message
> > > > > news:DcicnZCda82qv_HdSa8jmw@karoo.co.uk...
> > > > > > Hey CJ,
> > > > > >
> > > > > > Hows you doing?
> > > > > >
> > > > > > Right i`ve added Private WithEvents cmDsAccess As[/color][/color][/color]
CurrencyManager[color=blue]
> in[color=green][color=darkred]
> > > 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[/color]
> > Combo[color=darkred]
> > > > box
> > > > > > as i select rows in my Datagrid?
> > > > > >
> > > > > > ManyThanks
> > > > > > MCN(Si)
> > > > > >
> > > > > > By Datasource, do you mean the
> > > > > > "CJ Taylor" <nospam@blowgoats.com> wrote in message
> > > > > > news:106o5vusiej5m11@corp.supernews.com...
> > > > > > > If they are associated with the same currency manager it will[/color][/color][/color]
do[color=blue][color=green]
> > it[color=darkred]
> > > > > > > automatically.
> > > > > > >
> > > > > > > However, the probably isn't the case. anyways, in ADO.NET you[/color]
> > have[color=darkred]
> > > > > these
> > > > > > > things called CurrencyManagers that basically act kinda like[/color][/color][/color]
an[color=blue][color=green]
> > old[color=darkred]
> > > > > > > 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[/color][/color]
> datagrid[color=green][color=darkred]
> > > > events
> > > > > > (or
> > > > > > > vise versa, either way, upon changing the position in a[/color][/color][/color]
datagrid[color=blue][color=green][color=darkred]
> > > (i.e
> > > > > > moving
> > > > > > > to a new row) the currency managers position is changed for[/color][/color][/color]
you[color=blue][color=green]
> > and[color=darkred]
> > > 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[/color][/color][/color]
others[color=blue][color=green][color=darkred]
> > > 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)[/color][/color]
> you[color=green][color=darkred]
> > > can
> > > > > > find
> > > > > > > the variable _cmMyDataSet Variable and the events associated[/color][/color]
> with[color=green]
> > it[color=darkred]
> > > > on
> > > > > > the
> > > > > > > right.
> > > > > > >
> > > > > > > Subscribe to the PositionChanged event, and then you can do[/color]
> > whatever[color=darkred]
> > > > you
> > > > > > > want. (i.e something with your combobox based on new row[/color][/color][/color]
data).[color=blue][color=green][color=darkred]
> > > > > > >
> > > > > > > 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[/color][/color]
> lists[color=green][color=darkred]
> > > > (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[/color]
> > process[color=darkred]
> > > of
> > > > > > > repainting a control because of the ListChanged event on an
> > > > IListSource
> > > > > > > item.
> > > > > > >
> > > > > > > HTH,
> > > > > > > CJ
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > "MadCrazyNewbie" <test@nospam.com> wrote in message
> > > > > > > news:yG-dnSL3u-n8fvbdSa8jmw@karoo.co.uk...
> > > > > > > > Hey Group,
> > > > > > > >
> > > > > > > > Sorry but i`ve been searching everywhere for this even went[/color][/color]
> out[color=green][color=darkred]
> > > 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[/color][/color][/color]
<> -1[color=blue][color=green]
> > Then[color=darkred]
> > > > > > > > Me.ComboBox1.SelectedValue =
> > > > > > > > objdsAccess.Users.Rows(Me.BindingContext(objdsAcce ss,
> > > > > > > > "Users").Position).Item("AccessLevelID")
> > > > > > > > End If
> > > > > > > > Me.lblNavLocation.Text =[/color][/color][/color]
(((Me.BindingContext(objdsAccess,[color=blue][color=green][color=darkred]
> > > > > > > > "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[/color]
> > Object,[color=darkred]
> > > > > ByVal
> > > > > > e
> > > > > > > > As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
> > > > > > > > If Me.BindingContext(objdsAccess, "Users").Position[/color][/color][/color]
<> -1[color=blue][color=green]
> > And[color=darkred]
> > > > Not
> > > > > > > > mlLoading Then
> > > > > > > >[/color][/color][/color]
objdsAccess.Users.Rows(Me.BindingContext(objdsAcce ss,[color=blue][color=green][color=darkred]
> > > > > > > > "Users").Position).Item("AccessLevelID") =
> > > > Me.ComboBox1.SelectedValue
> > > > > > > > End If
> > > > > > > > End Sub
> > > > > > > >
> > > > > > > > This all works fine, if im using Navigation buttons and[/color][/color]
> calling:[color=green][color=darkred]
> > > > > > > > Me.objdsAccess_PositionChanged().
> > > > > > > >
> > > > > > > > However I`ve now added a Datagrid to my Form, as I select a[/color][/color]
> Row[color=green]
> > in[color=darkred]
> > > > my
> > > > > > > form.
> > > > > > > > How would i get it to update my ComboBox, and notice the[/color]
> > position[color=darkred]
> > > > > > changed?
> > > > > > > >
> > > > > > > > Thanks
> > > > > > > > MCN
> > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >[/color]
> >
> >[/color]
>
>[/color]


CJ Taylor
Guest
 
Posts: n/a
#10: Nov 20 '05

re: Sorry to Re-Post - Databindings problem


Simon,

Alright, in your form load create a currency manager (using your
_cmDsAccess) with

_cmDsAccess = BindingContext(objdsAccess, "Users")

now you previously declared this as

private WithEvents _cmDsAccess as CurrencyManager

then you want to create a method such as

Private Sub _cmDsAccess_PositionChanged(ByVal sender As Object, ByVal e As
System.EventArgs) Handles _cmDsAccess.PositionChanged





inisde this method is where you want to do

objdsAccess_PositionChanged()

try it out.



-CJ

"MadCrazyNewbie" <test@nospam.com> wrote in message
news:fLScnWBNF6D6qPHdSa8jmA@karoo.co.uk...[color=blue]
> From my Nav buttons I call objDsAccess_PostitionChanged() for example:
>
> Private Sub btnNavFirst_Click(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles btnNavFirst.Click
> Me.BindingContext(objdsAccess, "Users").Position = 0
> Me.objdsAccess_PositionChanged()
> End Sub
>
> My Datatable is bound to objdsAccess.Users.
>
> I have a relationship Setup from my Users Table, AccessID row to my
> AccessLevel Table AccessID.
>
> My AccessLevelID Table has a AccessLevel Feild in it to which my ComboBox
> Looks at.
>
> Ta
> MCN(Si)
>
> "CJ Taylor" <nospam@blowgoats.com> wrote in message
> news:106ocj9bf90ct2c@corp.supernews.com...[color=green]
> > Killin me dog.
> >
> > Alright, lets back it up a little bit. =)
> >
> > 1) objdsAccess_PositionChanged()
> >
> > How is this called? what causes this to be called.?
> >
> >
> >
> > 2) Me.BindingContext(objdsAccess, "Users").
> >
> > that right there is a currency manager. you can assign a variable to[/color][/color]
it,[color=blue][color=green]
> > makes things easier. Is your datagrid bound to this datatable on the
> > objDsAccess? what table is it bound to?
> >
> >
> >
> > "MadCrazyNewbie" <test@nospam.com> wrote in message
> > news:u7qcnXP5FrCprPHdSa8jmA@karoo.co.uk...[color=darkred]
> > > Sorry CJ, I Must be going blind.
> > >
> > > I think im going mad aswell and probably missing the point:(
> > >
> > > How do i get it to do my positions changed? I have my Nav buttons[/color][/color][/color]
setup[color=blue]
> to[color=green][color=darkred]
> > > call: Me.objDsAccess_PositionChanged.
> > >
> > > My Position Change code is as follows:
> > >
> > > 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 ") +[/color][/color]
> Me.BindingContext(objdsAccess,[color=green][color=darkred]
> > > "Users").Count.ToString)
> > > End Sub
> > >
> > > How do i get this to work for my Datagrid. Do I need a:
> > > Datagrid1_SelectedIndexChanged. Sorry i don`t know where to call a[/color][/color]
> datgird[color=green][color=darkred]
> > > PostionChanged from or am I barking up the wrong tree?
> > >
> > > Sorry to be a pain.
> > >
> > > Cheers
> > > MCN(Si)
> > >
> > > "CJ Taylor" <nospam@blowgoats.com> wrote in message
> > > news:106obctc5u2pc39@corp.supernews.com...
> > > > Go to your Code Window... Look at the combo box on the top left[/color][/color]
> side..[color=green][color=darkred]
> > > you
> > > > can't miss it.. there are two of them. right above your code. look
> > > there.
> > > > =)
> > > >
> > > >
> > > >
> > > >
> > > > "MadCrazyNewbie" <test@nospam.com> wrote in message
> > > > news:iv-cnWPk1byYsfHdSa8jmw@karoo.co.uk...
> > > > > CJ
> > > > >
> > > > > Im not to bad been really busy with work and wot not:( All work[/color][/color][/color]
and[color=blue]
> no[color=green][color=darkred]
> > > > > play:(
> > > > >
> > > > > Anyways ....... I`ve looked in my propery Browser but i carn`t[/color][/color][/color]
seem[color=blue]
> to[color=green][color=darkred]
> > > > find
> > > > > cmDsAccess anywhere in there:(
> > > > >
> > > > > Any Ideas?
> > > > >
> > > > > Ta
> > > > > MCN(Si)
> > > > >
> > > > > "CJ Taylor" <nospam@blowgoats.com> wrote in message
> > > > > news:106oa42e5ir6349@corp.supernews.com...
> > > > > > Simon,
> > > > > >
> > > > > > since you declared your cmDsAccess WithEvents you can look up in[/color][/color]
> the[color=green][color=darkred]
> > > top
> > > > > > left dropdown where it describes all you objects etc (like[/color][/color]
> textboxes[color=green][color=darkred]
> > > and
> > > > > so
> > > > > > on).
> > > > > >
> > > > > > in there you will see your cmDsAccess object. If you click on[/color][/color][/color]
it,[color=blue][color=green][color=darkred]
> > > > you'll
> > > > > > see the events on the right side combo box. One of those will[/color][/color][/color]
be[color=blue][color=green][color=darkred]
> > > > position
> > > > > > changed.
> > > > > >
> > > > > > click it (subscribing to it) and then that is your notifcation[/color][/color]
> that[color=green][color=darkred]
> > > the
> > > > > row
> > > > > > position has changed within your datagrid. At that point, you[/color][/color][/color]
can[color=blue][color=green]
> > do[color=darkred]
> > > > > > whatever you want. for exmaple, on your position chaged event[/color][/color][/color]
you[color=blue][color=green]
> > can[color=darkred]
> > > > get
> > > > > > the current row from the currency manager (cmDsAccess.Current())[/color][/color]
> and[color=green][color=darkred]
> > > > > > maniuplate your combo boxes based off that.
> > > > > >
> > > > > > How are things? Things are busy as sh**
> > > > > >
> > > > > > =)
> > > > > >
> > > > > > -CJ
> > > > > >
> > > > > > "MadCrazyNewbie" <test@nospam.com> wrote in message
> > > > > > news:DcicnZCda82qv_HdSa8jmw@karoo.co.uk...
> > > > > > > Hey CJ,
> > > > > > >
> > > > > > > Hows you doing?
> > > > > > >
> > > > > > > Right i`ve added Private WithEvents cmDsAccess As[/color][/color]
> CurrencyManager[color=green]
> > in[color=darkred]
> > > > 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,[/color][/color][/color]
and[color=blue][color=green][color=darkred]
> > > Combo
> > > > > box
> > > > > > > as i select rows in my Datagrid?
> > > > > > >
> > > > > > > ManyThanks
> > > > > > > MCN(Si)
> > > > > > >
> > > > > > > By Datasource, do you mean the
> > > > > > > "CJ Taylor" <nospam@blowgoats.com> wrote in message
> > > > > > > news:106o5vusiej5m11@corp.supernews.com...
> > > > > > > > If they are associated with the same currency manager it[/color][/color][/color]
will[color=blue]
> do[color=green][color=darkred]
> > > it
> > > > > > > > automatically.
> > > > > > > >
> > > > > > > > However, the probably isn't the case. anyways, in ADO.NET[/color][/color][/color]
you[color=blue][color=green][color=darkred]
> > > have
> > > > > > these
> > > > > > > > things called CurrencyManagers that basically act kinda like[/color][/color]
> an[color=green][color=darkred]
> > > 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[/color]
> > datagrid[color=darkred]
> > > > > events
> > > > > > > (or
> > > > > > > > vise versa, either way, upon changing the position in a[/color][/color]
> datagrid[color=green][color=darkred]
> > > > (i.e
> > > > > > > moving
> > > > > > > > to a new row) the currency managers position is changed for[/color][/color]
> you[color=green][color=darkred]
> > > 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[/color][/color]
> others[color=green][color=darkred]
> > > > like
> > > > > in
> > > > > > > > your constructor, but not really a big deal.
> > > > > > > >
> > > > > > > > _cmMyDataSet = BindingContext(myDataSource, "myDataTable")
> > > > > > > >
> > > > > > > > Obviously replace those with valid values for your dataset[/color][/color][/color]
and[color=blue][color=green][color=darkred]
> > > > > > datatable.
> > > > > > > >
> > > > > > > > Then, in your property browser on the top left (the drop[/color][/color][/color]
down)[color=blue][color=green]
> > you[color=darkred]
> > > > can
> > > > > > > find
> > > > > > > > the variable _cmMyDataSet Variable and the events associated[/color]
> > with[color=darkred]
> > > 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[/color][/color]
> data).[color=green][color=darkred]
> > > > > > > >
> > > > > > > > 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[/color]
> > lists[color=darkred]
> > > > > (i.e.
> > > > > > > > filling a large dataset) you can use suspendbinding while[/color][/color][/color]
your[color=blue][color=green][color=darkred]
> > > > 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" <test@nospam.com> wrote in message
> > > > > > > > news:yG-dnSL3u-n8fvbdSa8jmw@karoo.co.uk...
> > > > > > > > > Hey Group,
> > > > > > > > >
> > > > > > > > > Sorry but i`ve been searching everywhere for this even[/color][/color][/color]
went[color=blue][color=green]
> > out[color=darkred]
> > > > 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[/color][/color]
> <> -1[color=green][color=darkred]
> > > Then
> > > > > > > > > Me.ComboBox1.SelectedValue =
> > > > > > > > > objdsAccess.Users.Rows(Me.BindingContext(objdsAcce ss,
> > > > > > > > > "Users").Position).Item("AccessLevelID")
> > > > > > > > > End If
> > > > > > > > > Me.lblNavLocation.Text =[/color][/color]
> (((Me.BindingContext(objdsAccess,[color=green][color=darkred]
> > > > > > > > > "Users").Position + 1).ToString + " of ") +
> > > > > > > > Me.BindingContext(objdsAccess,
> > > > > > > > > "Users").Count.ToString)
> > > > > > > > > End Sub
> > > > > > > > >
> > > > > > > > > This works fine, with my Combo Box. My ComboBox is using[/color][/color][/color]
the[color=blue][color=green][color=darkred]
> > > > > following
> > > > > > > > code:
> > > > > > > > >
> > > > > > > > > Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As
> > > Object,
> > > > > > ByVal
> > > > > > > e
> > > > > > > > > As System.EventArgs) Handles[/color][/color][/color]
ComboBox1.SelectedIndexChanged[color=blue][color=green][color=darkred]
> > > > > > > > > If Me.BindingContext(objdsAccess, "Users").Position[/color][/color]
> <> -1[color=green][color=darkred]
> > > And
> > > > > Not
> > > > > > > > > mlLoading Then
> > > > > > > > >[/color][/color]
> objdsAccess.Users.Rows(Me.BindingContext(objdsAcce ss,[color=green][color=darkred]
> > > > > > > > > "Users").Position).Item("AccessLevelID") =
> > > > > Me.ComboBox1.SelectedValue
> > > > > > > > > End If
> > > > > > > > > End Sub
> > > > > > > > >
> > > > > > > > > This all works fine, if im using Navigation buttons and[/color]
> > calling:[color=darkred]
> > > > > > > > > Me.objdsAccess_PositionChanged().
> > > > > > > > >
> > > > > > > > > However I`ve now added a Datagrid to my Form, as I select[/color][/color][/color]
a[color=blue][color=green]
> > Row[color=darkred]
> > > in
> > > > > my
> > > > > > > > form.
> > > > > > > > > How would i get it to update my ComboBox, and notice the
> > > position
> > > > > > > changed?
> > > > > > > > >
> > > > > > > > > Thanks
> > > > > > > > > MCN
> > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >[/color]
> >
> >[/color]
>
>[/color]


MadCrazyNewbie
Guest
 
Posts: n/a
#11: Nov 20 '05

re: Sorry to Re-Post - Databindings problem


CJ,

I`ve done the below but with no joy:(

i`ve mailed you privatly with my App attached, i tryed to post my App here
(60kb) but it dosn`t seem to want to post:(

Cheers
MCN(Si)

"CJ Taylor" <nospam@blowgoats.com> wrote in message
news:106oes1gg32sr25@corp.supernews.com...[color=blue]
> Simon,
>
> Alright, in your form load create a currency manager (using your
> _cmDsAccess) with
>
> _cmDsAccess = BindingContext(objdsAccess, "Users")
>
> now you previously declared this as
>
> private WithEvents _cmDsAccess as CurrencyManager
>
> then you want to create a method such as
>
> Private Sub _cmDsAccess_PositionChanged(ByVal sender As Object, ByVal e As
> System.EventArgs) Handles _cmDsAccess.PositionChanged
>
>
>
>
>
> inisde this method is where you want to do
>
> objdsAccess_PositionChanged()
>
> try it out.
>
>
>
> -CJ
>
> "MadCrazyNewbie" <test@nospam.com> wrote in message
> news:fLScnWBNF6D6qPHdSa8jmA@karoo.co.uk...[color=green]
> > From my Nav buttons I call objDsAccess_PostitionChanged() for example:
> >
> > Private Sub btnNavFirst_Click(ByVal sender As System.Object, ByVal e As
> > System.EventArgs) Handles btnNavFirst.Click
> > Me.BindingContext(objdsAccess, "Users").Position = 0
> > Me.objdsAccess_PositionChanged()
> > End Sub
> >
> > My Datatable is bound to objdsAccess.Users.
> >
> > I have a relationship Setup from my Users Table, AccessID row to my
> > AccessLevel Table AccessID.
> >
> > My AccessLevelID Table has a AccessLevel Feild in it to which my[/color][/color]
ComboBox[color=blue][color=green]
> > Looks at.
> >
> > Ta
> > MCN(Si)
> >
> > "CJ Taylor" <nospam@blowgoats.com> wrote in message
> > news:106ocj9bf90ct2c@corp.supernews.com...[color=darkred]
> > > Killin me dog.
> > >
> > > Alright, lets back it up a little bit. =)
> > >
> > > 1) objdsAccess_PositionChanged()
> > >
> > > How is this called? what causes this to be called.?
> > >
> > >
> > >
> > > 2) Me.BindingContext(objdsAccess, "Users").
> > >
> > > that right there is a currency manager. you can assign a variable to[/color][/color]
> it,[color=green][color=darkred]
> > > makes things easier. Is your datagrid bound to this datatable on the
> > > objDsAccess? what table is it bound to?
> > >
> > >
> > >
> > > "MadCrazyNewbie" <test@nospam.com> wrote in message
> > > news:u7qcnXP5FrCprPHdSa8jmA@karoo.co.uk...
> > > > Sorry CJ, I Must be going blind.
> > > >
> > > > I think im going mad aswell and probably missing the point:(
> > > >
> > > > How do i get it to do my positions changed? I have my Nav buttons[/color][/color]
> setup[color=green]
> > to[color=darkred]
> > > > call: Me.objDsAccess_PositionChanged.
> > > >
> > > > My Position Change code is as follows:
> > > >
> > > > 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 ") +[/color]
> > Me.BindingContext(objdsAccess,[color=darkred]
> > > > "Users").Count.ToString)
> > > > End Sub
> > > >
> > > > How do i get this to work for my Datagrid. Do I need a:
> > > > Datagrid1_SelectedIndexChanged. Sorry i don`t know where to call a[/color]
> > datgird[color=darkred]
> > > > PostionChanged from or am I barking up the wrong tree?
> > > >
> > > > Sorry to be a pain.
> > > >
> > > > Cheers
> > > > MCN(Si)
> > > >
> > > > "CJ Taylor" <nospam@blowgoats.com> wrote in message
> > > > news:106obctc5u2pc39@corp.supernews.com...
> > > > > Go to your Code Window... Look at the combo box on the top left[/color]
> > side..[color=darkred]
> > > > you
> > > > > can't miss it.. there are two of them. right above your code.[/color][/color][/color]
look[color=blue][color=green][color=darkred]
> > > > there.
> > > > > =)
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > "MadCrazyNewbie" <test@nospam.com> wrote in message
> > > > > news:iv-cnWPk1byYsfHdSa8jmw@karoo.co.uk...
> > > > > > CJ
> > > > > >
> > > > > > Im not to bad been really busy with work and wot not:( All work[/color][/color]
> and[color=green]
> > no[color=darkred]
> > > > > > play:(
> > > > > >
> > > > > > Anyways ....... I`ve looked in my propery Browser but i carn`t[/color][/color]
> seem[color=green]
> > to[color=darkred]
> > > > > find
> > > > > > cmDsAccess anywhere in there:(
> > > > > >
> > > > > > Any Ideas?
> > > > > >
> > > > > > Ta
> > > > > > MCN(Si)
> > > > > >
> > > > > > "CJ Taylor" <nospam@blowgoats.com> wrote in message
> > > > > > news:106oa42e5ir6349@corp.supernews.com...
> > > > > > > Simon,
> > > > > > >
> > > > > > > since you declared your cmDsAccess WithEvents you can look up[/color][/color][/color]
in[color=blue][color=green]
> > the[color=darkred]
> > > > top
> > > > > > > left dropdown where it describes all you objects etc (like[/color]
> > textboxes[color=darkred]
> > > > and
> > > > > > so
> > > > > > > on).
> > > > > > >
> > > > > > > in there you will see your cmDsAccess object. If you click on[/color][/color]
> it,[color=green][color=darkred]
> > > > > you'll
> > > > > > > see the events on the right side combo box. One of those will[/color][/color]
> be[color=green][color=darkred]
> > > > > position
> > > > > > > changed.
> > > > > > >
> > > > > > > click it (subscribing to it) and then that is your notifcation[/color]
> > that[color=darkred]
> > > > the
> > > > > > row
> > > > > > > position has changed within your datagrid. At that point, you[/color][/color]
> can[color=green][color=darkred]
> > > do
> > > > > > > whatever you want. for exmaple, on your position chaged event[/color][/color]
> you[color=green][color=darkred]
> > > can
> > > > > get
> > > > > > > the current row from the currency manager[/color][/color][/color]
(cmDsAccess.Current())[color=blue][color=green]
> > and[color=darkred]
> > > > > > > maniuplate your combo boxes based off that.
> > > > > > >
> > > > > > > How are things? Things are busy as sh**
> > > > > > >
> > > > > > > =)
> > > > > > >
> > > > > > > -CJ
> > > > > > >
> > > > > > > "MadCrazyNewbie" <test@nospam.com> wrote in message
> > > > > > > news:DcicnZCda82qv_HdSa8jmw@karoo.co.uk...
> > > > > > > > Hey CJ,
> > > > > > > >
> > > > > > > > Hows you doing?
> > > > > > > >
> > > > > > > > Right i`ve added Private WithEvents cmDsAccess As[/color]
> > CurrencyManager[color=darkred]
> > > 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,[/color][/color]
> and[color=green][color=darkred]
> > > > Combo
> > > > > > box
> > > > > > > > as i select rows in my Datagrid?
> > > > > > > >
> > > > > > > > ManyThanks
> > > > > > > > MCN(Si)
> > > > > > > >
> > > > > > > > By Datasource, do you mean the
> > > > > > > > "CJ Taylor" <nospam@blowgoats.com> wrote in message
> > > > > > > > news:106o5vusiej5m11@corp.supernews.com...
> > > > > > > > > If they are associated with the same currency manager it[/color][/color]
> will[color=green]
> > do[color=darkred]
> > > > it
> > > > > > > > > automatically.
> > > > > > > > >
> > > > > > > > > However, the probably isn't the case. anyways, in ADO.NET[/color][/color]
> you[color=green][color=darkred]
> > > > have
> > > > > > > these
> > > > > > > > > things called CurrencyManagers that basically act kinda[/color][/color][/color]
like[color=blue][color=green]
> > an[color=darkred]
> > > > 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[/color]
> > datagrid[color=darkred]
> > > > > (i.e
> > > > > > > > moving
> > > > > > > > > to a new row) the currency managers position is changed[/color][/color][/color]
for[color=blue][color=green]
> > you[color=darkred]
> > > > 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[/color]
> > others[color=darkred]
> > > > > like
> > > > > > in
> > > > > > > > > your constructor, but not really a big deal.
> > > > > > > > >
> > > > > > > > > _cmMyDataSet = BindingContext(myDataSource, "myDataTable")
> > > > > > > > >
> > > > > > > > > Obviously replace those with valid values for your dataset[/color][/color]
> and[color=green][color=darkred]
> > > > > > > datatable.
> > > > > > > > >
> > > > > > > > > Then, in your property browser on the top left (the drop[/color][/color]
> down)[color=green][color=darkred]
> > > you
> > > > > can
> > > > > > > > find
> > > > > > > > > the variable _cmMyDataSet Variable and the events[/color][/color][/color]
associated[color=blue][color=green][color=darkred]
> > > with
> > > > it
> > > > > > on
> > > > > > > > the
> > > > > > > > > right.
> > > > > > > > >
> > > > > > > > > Subscribe to the PositionChanged event, and then you can[/color][/color][/color]
do[color=blue][color=green][color=darkred]
> > > > whatever
> > > > > > you
> > > > > > > > > want. (i.e something with your combobox based on new row[/color]
> > data).[color=darkred]
> > > > > > > > >
> > > > > > > > > CurrencyMangers are also INCREDIBLY useful when doing[/color][/color][/color]
record[color=blue][color=green][color=darkred]
> > > > > > > manipulation,
> > > > > > > > > because you can actually turn off the binding using the
> > > > > > > .SuspendBinding()
> > > > > > > > > and .ResumeBinding() methods, so if your working with[/color][/color][/color]
large[color=blue][color=green][color=darkred]
> > > lists
> > > > > > (i.e.
> > > > > > > > > filling a large dataset) you can use suspendbinding while[/color][/color]
> your[color=green][color=darkred]
> > > > > filling
> > > > > > > it
> > > > > > > > > (otherwise, every time an item is added it goes through[/color][/color][/color]
the[color=blue][color=green][color=darkred]
> > > > process
> > > > > of
> > > > > > > > > repainting a control because of the ListChanged event on[/color][/color][/color]
an[color=blue][color=green][color=darkred]
> > > > > > IListSource
> > > > > > > > > item.
> > > > > > > > >
> > > > > > > > > HTH,
> > > > > > > > > CJ
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > "MadCrazyNewbie" <test@nospam.com> wrote in message
> > > > > > > > > news:yG-dnSL3u-n8fvbdSa8jmw@karoo.co.uk...
> > > > > > > > > > Hey Group,
> > > > > > > > > >
> > > > > > > > > > Sorry but i`ve been searching everywhere for this even[/color][/color]
> went[color=green][color=darkred]
> > > 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[/color]
> > <> -1[color=darkred]
> > > > Then
> > > > > > > > > > Me.ComboBox1.SelectedValue =
> > > > > > > > > > objdsAccess.Users.Rows(Me.BindingContext(objdsAcce ss,
> > > > > > > > > > "Users").Position).Item("AccessLevelID")
> > > > > > > > > > End If
> > > > > > > > > > Me.lblNavLocation.Text =[/color]
> > (((Me.BindingContext(objdsAccess,[color=darkred]
> > > > > > > > > > "Users").Position + 1).ToString + " of ") +
> > > > > > > > > Me.BindingContext(objdsAccess,
> > > > > > > > > > "Users").Count.ToString)
> > > > > > > > > > End Sub
> > > > > > > > > >
> > > > > > > > > > This works fine, with my Combo Box. My ComboBox is using[/color][/color]
> the[color=green][color=darkred]
> > > > > > following
> > > > > > > > > code:
> > > > > > > > > >
> > > > > > > > > > Private Sub ComboBox1_SelectedIndexChanged(ByVal sender[/color][/color][/color]
As[color=blue][color=green][color=darkred]
> > > > Object,
> > > > > > > ByVal
> > > > > > > > e
> > > > > > > > > > As System.EventArgs) Handles[/color][/color]
> ComboBox1.SelectedIndexChanged[color=green][color=darkred]
> > > > > > > > > > If Me.BindingContext(objdsAccess, "Users").Position[/color]
> > <> -1[color=darkred]
> > > > And
> > > > > > Not
> > > > > > > > > > mlLoading Then
> > > > > > > > > >[/color]
> > objdsAccess.Users.Rows(Me.BindingContext(objdsAcce ss,[color=darkred]
> > > > > > > > > > "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[/color][/color][/color]
select[color=blue]
> a[color=green][color=darkred]
> > > Row
> > > > in
> > > > > > my
> > > > > > > > > form.
> > > > > > > > > > How would i get it to update my ComboBox, and notice the
> > > > position
> > > > > > > > changed?
> > > > > > > > > >
> > > > > > > > > > Thanks
> > > > > > > > > > MCN
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >[/color]
> >
> >[/color]
>
>[/color]


CJ Taylor
Guest
 
Posts: n/a
#12: Nov 20 '05

re: Sorry to Re-Post - Databindings problem


simon, give me some time to get it... may not be till tonight. can't access
home email from here.

"MadCrazyNewbie" <test@nospam.com> wrote in message
news:NJidnY85I-jV0_HdSa8jmw@karoo.co.uk...[color=blue]
> CJ,
>
> I`ve done the below but with no joy:(
>
> i`ve mailed you privatly with my App attached, i tryed to post my App[/color]
here[color=blue]
> (60kb) but it dosn`t seem to want to post:(
>
> Cheers
> MCN(Si)
>
> "CJ Taylor" <nospam@blowgoats.com> wrote in message
> news:106oes1gg32sr25@corp.supernews.com...[color=green]
> > Simon,
> >
> > Alright, in your form load create a currency manager (using your
> > _cmDsAccess) with
> >
> > _cmDsAccess = BindingContext(objdsAccess, "Users")
> >
> > now you previously declared this as
> >
> > private WithEvents _cmDsAccess as CurrencyManager
> >
> > then you want to create a method such as
> >
> > Private Sub _cmDsAccess_PositionChanged(ByVal sender As Object, ByVal e[/color][/color]
As[color=blue][color=green]
> > System.EventArgs) Handles _cmDsAccess.PositionChanged
> >
> >
> >
> >
> >
> > inisde this method is where you want to do
> >
> > objdsAccess_PositionChanged()
> >
> > try it out.
> >
> >
> >
> > -CJ
> >
> > "MadCrazyNewbie" <test@nospam.com> wrote in message
> > news:fLScnWBNF6D6qPHdSa8jmA@karoo.co.uk...[color=darkred]
> > > From my Nav buttons I call objDsAccess_PostitionChanged() for example:
> > >
> > > Private Sub btnNavFirst_Click(ByVal sender As System.Object, ByVal e[/color][/color][/color]
As[color=blue][color=green][color=darkred]
> > > System.EventArgs) Handles btnNavFirst.Click
> > > Me.BindingContext(objdsAccess, "Users").Position = 0
> > > Me.objdsAccess_PositionChanged()
> > > End Sub
> > >
> > > My Datatable is bound to objdsAccess.Users.
> > >
> > > I have a relationship Setup from my Users Table, AccessID row to my
> > > AccessLevel Table AccessID.
> > >
> > > My AccessLevelID Table has a AccessLevel Feild in it to which my[/color][/color]
> ComboBox[color=green][color=darkred]
> > > Looks at.
> > >
> > > Ta
> > > MCN(Si)
> > >
> > > "CJ Taylor" <nospam@blowgoats.com> wrote in message
> > > news:106ocj9bf90ct2c@corp.supernews.com...
> > > > Killin me dog.
> > > >
> > > > Alright, lets back it up a little bit. =)
> > > >
> > > > 1) objdsAccess_PositionChanged()
> > > >
> > > > How is this called? what causes this to be called.?
> > > >
> > > >
> > > >
> > > > 2) Me.BindingContext(objdsAccess, "Users").
> > > >
> > > > that right there is a currency manager. you can assign a variable[/color][/color][/color]
to[color=blue][color=green]
> > it,[color=darkred]
> > > > makes things easier. Is your datagrid bound to this datatable on[/color][/color][/color]
the[color=blue][color=green][color=darkred]
> > > > objDsAccess? what table is it bound to?
> > > >
> > > >
> > > >
> > > > "MadCrazyNewbie" <test@nospam.com> wrote in message
> > > > news:u7qcnXP5FrCprPHdSa8jmA@karoo.co.uk...
> > > > > Sorry CJ, I Must be going blind.
> > > > >
> > > > > I think im going mad aswell and probably missing the point:(
> > > > >
> > > > > How do i get it to do my positions changed? I have my Nav buttons[/color]
> > setup[color=darkred]
> > > to
> > > > > call: Me.objDsAccess_PositionChanged.
> > > > >
> > > > > My Position Change code is as follows:
> > > > >
> > > > > 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
> > > > >
> > > > > How do i get this to work for my Datagrid. Do I need a:
> > > > > Datagrid1_SelectedIndexChanged. Sorry i don`t know where to call a
> > > datgird
> > > > > PostionChanged from or am I barking up the wrong tree?
> > > > >
> > > > > Sorry to be a pain.
> > > > >
> > > > > Cheers
> > > > > MCN(Si)
> > > > >
> > > > > "CJ Taylor" <nospam@blowgoats.com> wrote in message
> > > > > news:106obctc5u2pc39@corp.supernews.com...
> > > > > > Go to your Code Window... Look at the combo box on the top left
> > > side..
> > > > > you
> > > > > > can't miss it.. there are two of them. right above your code.[/color][/color]
> look[color=green][color=darkred]
> > > > > there.
> > > > > > =)
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > > "MadCrazyNewbie" <test@nospam.com> wrote in message
> > > > > > news:iv-cnWPk1byYsfHdSa8jmw@karoo.co.uk...
> > > > > > > CJ
> > > > > > >
> > > > > > > Im not to bad been really busy with work and wot not:( All[/color][/color][/color]
work[color=blue][color=green]
> > and[color=darkred]
> > > no
> > > > > > > play:(
> > > > > > >
> > > > > > > Anyways ....... I`ve looked in my propery Browser but i carn`t[/color]
> > seem[color=darkred]
> > > to
> > > > > > find
> > > > > > > cmDsAccess anywhere in there:(
> > > > > > >
> > > > > > > Any Ideas?
> > > > > > >
> > > > > > > Ta
> > > > > > > MCN(Si)
> > > > > > >
> > > > > > > "CJ Taylor" <nospam@blowgoats.com> wrote in message
> > > > > > > news:106oa42e5ir6349@corp.supernews.com...
> > > > > > > > Simon,
> > > > > > > >
> > > > > > > > since you declared your cmDsAccess WithEvents you can look[/color][/color][/color]
up[color=blue]
> in[color=green][color=darkred]
> > > 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[/color][/color][/color]
on[color=blue][color=green]
> > it,[color=darkred]
> > > > > > you'll
> > > > > > > > see the events on the right side combo box. One of those[/color][/color][/color]
will[color=blue][color=green]
> > be[color=darkred]
> > > > > > position
> > > > > > > > changed.
> > > > > > > >
> > > > > > > > click it (subscribing to it) and then that is your[/color][/color][/color]
notifcation[color=blue][color=green][color=darkred]
> > > that
> > > > > the
> > > > > > > row
> > > > > > > > position has changed within your datagrid. At that point,[/color][/color][/color]
you[color=blue][color=green]
> > can[color=darkred]
> > > > do
> > > > > > > > whatever you want. for exmaple, on your position chaged[/color][/color][/color]
event[color=blue][color=green]
> > you[color=darkred]
> > > > can
> > > > > > get
> > > > > > > > the current row from the currency manager[/color][/color]
> (cmDsAccess.Current())[color=green][color=darkred]
> > > and
> > > > > > > > maniuplate your combo boxes based off that.
> > > > > > > >
> > > > > > > > How are things? Things are busy as sh**
> > > > > > > >
> > > > > > > > =)
> > > > > > > >
> > > > > > > > -CJ
> > > > > > > >
> > > > > > > > "MadCrazyNewbie" <test@nospam.com> wrote in message
> > > > > > > > news:DcicnZCda82qv_HdSa8jmw@karoo.co.uk...
> > > > > > > > > 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[/color][/color][/color]
textboxs,[color=blue][color=green]
> > and[color=darkred]
> > > > > Combo
> > > > > > > box
> > > > > > > > > as i select rows in my Datagrid?
> > > > > > > > >
> > > > > > > > > ManyThanks
> > > > > > > > > MCN(Si)
> > > > > > > > >
> > > > > > > > > By Datasource, do you mean the
> > > > > > > > > "CJ Taylor" <nospam@blowgoats.com> wrote in message
> > > > > > > > > news:106o5vusiej5m11@corp.supernews.com...
> > > > > > > > > > If they are associated with the same currency manager it[/color]
> > will[color=darkred]
> > > do
> > > > > it
> > > > > > > > > > automatically.
> > > > > > > > > >
> > > > > > > > > > However, the probably isn't the case. anyways, in[/color][/color][/color]
ADO.NET[color=blue][color=green]
> > you[color=darkred]
> > > > > have
> > > > > > > > these
> > > > > > > > > > things called CurrencyManagers that basically act kinda[/color][/color]
> like[color=green][color=darkred]
> > > an
> > > > > old
> > > > > > > > > > ADODB.Recordset (yes like many things in .NET).[/color][/color][/color]
Anyways,[color=blue][color=green][color=darkred]
> > > > > > > > CurrencyManagers
> > > > > > > > > > are created from bindings (actually you get them from[/color][/color][/color]
the[color=blue][color=green][color=darkred]
> > > > > > > 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[/color][/color]
> for[color=green][color=darkred]
> > > 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[/color][/color][/color]
it[color=blue][color=green][color=darkred]
> > > others
> > > > > > like
> > > > > > > in
> > > > > > > > > > your constructor, but not really a big deal.
> > > > > > > > > >
> > > > > > > > > > _cmMyDataSet = BindingContext(myDataSource,[/color][/color][/color]
"myDataTable")[color=blue][color=green][color=darkred]
> > > > > > > > > >
> > > > > > > > > > Obviously replace those with valid values for your[/color][/color][/color]
dataset[color=blue][color=green]
> > and[color=darkred]
> > > > > > > > datatable.
> > > > > > > > > >
> > > > > > > > > > Then, in your property browser on the top left (the drop[/color]
> > down)[color=darkred]
> > > > you
> > > > > > can
> > > > > > > > > find
> > > > > > > > > > the variable _cmMyDataSet Variable and the events[/color][/color]
> associated[color=green][color=darkred]
> > > > with
> > > > > it
> > > > > > > on
> > > > > > > > > the
> > > > > > > > > > right.
> > > > > > > > > >
> > > > > > > > > > Subscribe to the PositionChanged event, and then you can[/color][/color]
> do[color=green][color=darkred]
> > > > > whatever
> > > > > > > you
> > > > > > > > > > want. (i.e something with your combobox based on new row
> > > data).
> > > > > > > > > >
> > > > > > > > > > CurrencyMangers are also INCREDIBLY useful when doing[/color][/color]
> record[color=green][color=darkred]
> > > > > > > > manipulation,
> > > > > > > > > > because you can actually turn off the binding using the
> > > > > > > > .SuspendBinding()
> > > > > > > > > > and .ResumeBinding() methods, so if your working with[/color][/color]
> large[color=green][color=darkred]
> > > > lists
> > > > > > > (i.e.
> > > > > > > > > > filling a large dataset) you can use suspendbinding[/color][/color][/color]
while[color=blue][color=green]
> > your[color=darkred]
> > > > > > filling
> > > > > > > > it
> > > > > > > > > > (otherwise, every time an item is added it goes through[/color][/color]
> the[color=green][color=darkred]
> > > > > process
> > > > > > of
> > > > > > > > > > repainting a control because of the ListChanged event on[/color][/color]
> an[color=green][color=darkred]
> > > > > > > IListSource
> > > > > > > > > > item.
> > > > > > > > > >
> > > > > > > > > > HTH,
> > > > > > > > > > CJ
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > "MadCrazyNewbie" <test@nospam.com> wrote in message
> > > > > > > > > > news:yG-dnSL3u-n8fvbdSa8jmw@karoo.co.uk...
> > > > > > > > > > > Hey Group,
> > > > > > > > > > >
> > > > > > > > > > > Sorry but i`ve been searching everywhere for this even[/color]
> > went[color=darkred]
> > > > 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,[/color][/color][/color]
"Users").Position[color=blue][color=green][color=darkred]
> > > <> -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[/color][/color][/color]
using[color=blue][color=green]
> > the[color=darkred]
> > > > > > > following
> > > > > > > > > > code:
> > > > > > > > > > >
> > > > > > > > > > > Private Sub ComboBox1_SelectedIndexChanged(ByVal[/color][/color][/color]
sender[color=blue]
> As[color=green][color=darkred]
> > > > > Object,
> > > > > > > > ByVal
> > > > > > > > > e
> > > > > > > > > > > As System.EventArgs) Handles[/color]
> > ComboBox1.SelectedIndexChanged[color=darkred]
> > > > > > > > > > > If Me.BindingContext(objdsAccess,[/color][/color][/color]
"Users").Position[color=blue][color=green][color=darkred]
> > > <> -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[/color][/color][/color]
and[color=blue][color=green][color=darkred]
> > > > calling:
> > > > > > > > > > > Me.objdsAccess_PositionChanged().
> > > > > > > > > > >
> > > > > > > > > > > However I`ve now added a Datagrid to my Form, as I[/color][/color]
> select[color=green]
> > a[color=darkred]
> > > > Row
> > > > > in
> > > > > > > my
> > > > > > > > > > form.
> > > > > > > > > > > How would i get it to update my ComboBox, and notice[/color][/color][/color]
the[color=blue][color=green][color=darkred]
> > > > > position
> > > > > > > > > changed?
> > > > > > > > > > >
> > > > > > > > > > > Thanks
> > > > > > > > > > > MCN
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >[/color]
> >
> >[/color]
>
>[/color]


CJ Taylor
Guest
 
Posts: n/a
#13: Nov 20 '05

re: Sorry to Re-Post - Databindings problem


simon, give me some time to get it... may not be till tonight. can't access
home email from here.

"MadCrazyNewbie" <test@nospam.com> wrote in message
news:NJidnY85I-jV0_HdSa8jmw@karoo.co.uk...[color=blue]
> CJ,
>
> I`ve done the below but with no joy:(
>
> i`ve mailed you privatly with my App attached, i tryed to post my App[/color]
here[color=blue]
> (60kb) but it dosn`t seem to want to post:(
>
> Cheers
> MCN(Si)
>
> "CJ Taylor" <nospam@blowgoats.com> wrote in message
> news:106oes1gg32sr25@corp.supernews.com...[color=green]
> > Simon,
> >
> > Alright, in your form load create a currency manager (using your
> > _cmDsAccess) with
> >
> > _cmDsAccess = BindingContext(objdsAccess, "Users")
> >
> > now you previously declared this as
> >
> > private WithEvents _cmDsAccess as CurrencyManager
> >
> > then you want to create a method such as
> >
> > Private Sub _cmDsAccess_PositionChanged(ByVal sender As Object, ByVal e[/color][/color]
As[color=blue][color=green]
> > System.EventArgs) Handles _cmDsAccess.PositionChanged
> >
> >
> >
> >
> >
> > inisde this method is where you want to do
> >
> > objdsAccess_PositionChanged()
> >
> > try it out.
> >
> >
> >
> > -CJ
> >
> > "MadCrazyNewbie" <test@nospam.com> wrote in message
> > news:fLScnWBNF6D6qPHdSa8jmA@karoo.co.uk...[color=darkred]
> > > From my Nav buttons I call objDsAccess_PostitionChanged() for example:
> > >
> > > Private Sub btnNavFirst_Click(ByVal sender As System.Object, ByVal e[/color][/color][/color]
As[color=blue][color=green][color=darkred]
> > > System.EventArgs) Handles btnNavFirst.Click
> > > Me.BindingContext(objdsAccess, "Users").Position = 0
> > > Me.objdsAccess_PositionChanged()
> > > End Sub
> > >
> > > My Datatable is bound to objdsAccess.Users.
> > >
> > > I have a relationship Setup from my Users Table, AccessID row to my
> > > AccessLevel Table AccessID.
> > >
> > > My AccessLevelID Table has a AccessLevel Feild in it to which my[/color][/color]
> ComboBox[color=green][color=darkred]
> > > Looks at.
> > >
> > > Ta
> > > MCN(Si)
> > >
> > > "CJ Taylor" <nospam@blowgoats.com> wrote in message
> > > news:106ocj9bf90ct2c@corp.supernews.com...
> > > > Killin me dog.
> > > >
> > > > Alright, lets back it up a little bit. =)
> > > >
> > > > 1) objdsAccess_PositionChanged()
> > > >
> > > > How is this called? what causes this to be called.?
> > > >
> > > >
> > > >
> > > > 2) Me.BindingContext(objdsAccess, "Users").
> > > >
> > > > that right there is a currency manager. you can assign a variable[/color][/color][/color]
to[color=blue][color=green]
> > it,[color=darkred]
> > > > makes things easier. Is your datagrid bound to this datatable on[/color][/color][/color]
the[color=blue][color=green][color=darkred]
> > > > objDsAccess? what table is it bound to?
> > > >
> > > >
> > > >
> > > > "MadCrazyNewbie" <test@nospam.com> wrote in message
> > > > news:u7qcnXP5FrCprPHdSa8jmA@karoo.co.uk...
> > > > > Sorry CJ, I Must be going blind.
> > > > >
> > > > > I think im going mad aswell and probably missing the point:(
> > > > >
> > > > > How do i get it to do my positions changed? I have my Nav buttons[/color]
> > setup[color=darkred]
> > > to
> > > > > call: Me.objDsAccess_PositionChanged.
> > > > >
> > > > > My Position Change code is as follows:
> > > > >
> > > > > 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
> > > > >
> > > > > How do i get this to work for my Datagrid. Do I need a:
> > > > > Datagrid1_SelectedIndexChanged. Sorry i don`t know where to call a
> > > datgird
> > > > > PostionChanged from or am I barking up the wrong tree?
> > > > >
> > > > > Sorry to be a pain.
> > > > >
> > > > > Cheers
> > > > > MCN(Si)
> > > > >
> > > > > "CJ Taylor" <nospam@blowgoats.com> wrote in message
> > > > > news:106obctc5u2pc39@corp.supernews.com...
> > > > > > Go to your Code Window... Look at the combo box on the top left
> > > side..
> > > > > you
> > > > > > can't miss it.. there are two of them. right above your code.[/color][/color]
> look[color=green][color=darkred]
> > > > > there.
> > > > > > =)
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > > "MadCrazyNewbie" <test@nospam.com> wrote in message
> > > > > > news:iv-cnWPk1byYsfHdSa8jmw@karoo.co.uk...
> > > > > > > CJ
> > > > > > >
> > > > > > > Im not to bad been really busy with work and wot not:( All[/color][/color][/color]
work[color=blue][color=green]
> > and[color=darkred]
> > > no
> > > > > > > play:(
> > > > > > >
> > > > > > > Anyways ....... I`ve looked in my propery Browser but i carn`t[/color]
> > seem[color=darkred]
> > > to
> > > > > > find
> > > > > > > cmDsAccess anywhere in there:(
> > > > > > >
> > > > > > > Any Ideas?
> > > > > > >
> > > > > > > Ta
> > > > > > > MCN(Si)
> > > > > > >
> > > > > > > "CJ Taylor" <nospam@blowgoats.com> wrote in message
> > > > > > > news:106oa42e5ir6349@corp.supernews.com...
> > > > > > > > Simon,
> > > > > > > >
> > > > > > > > since you declared your cmDsAccess WithEvents you can look[/color][/color][/color]
up[color=blue]
> in[color=green][color=darkred]
> > > 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[/color][/color][/color]
on[color=blue][color=green]
> > it,[color=darkred]
> > > > > > you'll
> > > > > > > > see the events on the right side combo box. One of those[/color][/color][/color]
will[color=blue][color=green]
> > be[color=darkred]
> > > > > > position
> > > > > > > > changed.
> > > > > > > >
> > > > > > > > click it (subscribing to it) and then that is your[/color][/color][/color]
notifcation[color=blue][color=green][color=darkred]
> > > that
> > > > > the
> > > > > > > row
> > > > > > > > position has changed within your datagrid. At that point,[/color][/color][/color]
you[color=blue][color=green]
> > can[color=darkred]
> > > > do
> > > > > > > > whatever you want. for exmaple, on your position chaged[/color][/color][/color]
event[color=blue][color=green]
> > you[color=darkred]
> > > > can
> > > > > > get
> > > > > > > > the current row from the currency manager[/color][/color]
> (cmDsAccess.Current())[color=green][color=darkred]
> > > and
> > > > > > > > maniuplate your combo boxes based off that.
> > > > > > > >
> > > > > > > > How are things? Things are busy as sh**
> > > > > > > >
> > > > > > > > =)
> > > > > > > >
> > > > > > > > -CJ
> > > > > > > >
> > > > > > > > "MadCrazyNewbie" <test@nospam.com> wrote in message
> > > > > > > > news:DcicnZCda82qv_HdSa8jmw@karoo.co.uk...
> > > > > > > > > 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[/color][/color][/color]
textboxs,[color=blue][color=green]
> > and[color=darkred]
> > > > > Combo
> > > > > > > box
> > > > > > > > > as i select rows in my Datagrid?
> > > > > > > > >
> > > > > > > > > ManyThanks
> > > > > > > > > MCN(Si)
> > > > > > > > >
> > > > > > > > > By Datasource, do you mean the
> > > > > > > > > "CJ Taylor" <nospam@blowgoats.com> wrote in message
> > > > > > > > > news:106o5vusiej5m11@corp.supernews.com...
> > > > > > > > > > If they are associated with the same currency manager it[/color]
> > will[color=darkred]
> > > do
> > > > > it
> > > > > > > > > > automatically.
> > > > > > > > > >
> > > > > > > > > > However, the probably isn't the case. anyways, in[/color][/color][/color]
ADO.NET[color=blue][color=green]
> > you[color=darkred]
> > > > > have
> > > > > > > > these
> > > > > > > > > > things called CurrencyManagers that basically act kinda[/color][/color]
> like[color=green][color=darkred]
> > > an
> > > > > old
> > > > > > > > > > ADODB.Recordset (yes like many things in .NET).[/color][/color][/color]
Anyways,[color=blue][color=green][color=darkred]
> > > > > > > > CurrencyManagers
> > > > > > > > > > are created from bindings (actually you get them from[/color][/color][/color]
the[color=blue][color=green][color=darkred]
> > > > > > > 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[/color][/color]
> for[color=green][color=darkred]
> > > 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[/color][/color][/color]
it[color=blue][color=green][color=darkred]
> > > others
> > > > > > like
> > > > > > > in
> > > > > > > > > > your constructor, but not really a big deal.
> > > > > > > > > >
> > > > > > > > > > _cmMyDataSet = BindingContext(myDataSource,[/color][/color][/color]
"myDataTable")[color=blue][color=green][color=darkred]
> > > > > > > > > >
> > > > > > > > > > Obviously replace those with valid values for your[/color][/color][/color]
dataset[color=blue][color=green]
> > and[color=darkred]
> > > > > > > > datatable.
> > > > > > > > > >
> > > > > > > > > > Then, in your property browser on the top left (the drop[/color]
> > down)[color=darkred]
> > > > you
> > > > > > can
> > > > > > > > > find
> > > > > > > > > > the variable _cmMyDataSet Variable and the events[/color][/color]
> associated[color=green][color=darkred]
> > > > with
> > > > > it
> > > > > > > on
> > > > > > > > > the
> > > > > > > > > > right.
> > > > > > > > > >
> > > > > > > > > > Subscribe to the PositionChanged event, and then you can[/color][/color]
> do[color=green][color=darkred]
> > > > > whatever
> > > > > > > you
> > > > > > > > > > want. (i.e something with your combobox based on new row
> > > data).
> > > > > > > > > >
> > > > > > > > > > CurrencyMangers are also INCREDIBLY useful when doing[/color][/color]
> record[color=green][color=darkred]
> > > > > > > > manipulation,
> > > > > > > > > > because you can actually turn off the binding using the
> > > > > > > > .SuspendBinding()
> > > > > > > > > > and .ResumeBinding() methods, so if your working with[/color][/color]
> large[color=green][color=darkred]
> > > > lists
> > > > > > > (i.e.
> > > > > > > > > > filling a large dataset) you can use suspendbinding[/color][/color][/color]
while[color=blue][color=green]
> > your[color=darkred]
> > > > > > filling
> > > > > > > > it
> > > > > > > > > > (otherwise, every time an item is added it goes through[/color][/color]
> the[color=green][color=darkred]
> > > > > process
> > > > > > of
> > > > > > > > > > repainting a control because of the ListChanged event on[/color][/color]
> an[color=green][color=darkred]
> > > > > > > IListSource
> > > > > > > > > > item.
> > > > > > > > > >
> > > > > > > > > > HTH,
> > > > > > > > > > CJ
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > "MadCrazyNewbie" <test@nospam.com> wrote in message
> > > > > > > > > > news:yG-dnSL3u-n8fvbdSa8jmw@karoo.co.uk...
> > > > > > > > > > > Hey Group,
> > > > > > > > > > >
> > > > > > > > > > > Sorry but i`ve been searching everywhere for this even[/color]
> > went[color=darkred]
> > > > 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,[/color][/color][/color]
"Users").Position[color=blue][color=green][color=darkred]
> > > <> -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[/color][/color][/color]
using[color=blue][color=green]
> > the[color=darkred]
> > > > > > > following
> > > > > > > > > > code:
> > > > > > > > > > >
> > > > > > > > > > > Private Sub ComboBox1_SelectedIndexChanged(ByVal[/color][/color][/color]
sender[color=blue]
> As[color=green][color=darkred]
> > > > > Object,
> > > > > > > > ByVal
> > > > > > > > > e
> > > > > > > > > > > As System.EventArgs) Handles[/color]
> > ComboBox1.SelectedIndexChanged[color=darkred]
> > > > > > > > > > > If Me.BindingContext(objdsAccess,[/color][/color][/color]
"Users").Position[color=blue][color=green][color=darkred]
> > > <> -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[/color][/color][/color]
and[color=blue][color=green][color=darkred]
> > > > calling:
> > > > > > > > > > > Me.objdsAccess_PositionChanged().
> > > > > > > > > > >
> > > > > > > > > > > However I`ve now added a Datagrid to my Form, as I[/color][/color]
> select[color=green]
> > a[color=darkred]
> > > > Row
> > > > > in
> > > > > > > my
> > > > > > > > > > form.
> > > > > > > > > > > How would i get it to update my ComboBox, and notice[/color][/color][/color]
the[color=blue][color=green][color=darkred]
> > > > > position
> > > > > > > > > changed?
> > > > > > > > > > >
> > > > > > > > > > > Thanks
> > > > > > > > > > > MCN
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >[/color]
> >
> >[/color]
>
>[/color]


Closed Thread