473,386 Members | 1,752 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Sorry to Re-Post - Databindings problem

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
Nov 20 '05 #1
8 1011
If they are associated with the same currency manager it will do it
automatically.

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

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

so the best way to handle this is.

In your class delcaration do this...

Private WithEvents _cmMyDataset as CurrencyManager

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

_cmMyDataSet = BindingContext(myDataSource, "myDataTable")

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

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

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

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

HTH,
CJ

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

Sorry but i`ve been searching everywhere for this even went out and bought 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

Nov 20 '05 #2
Hey CJ,

Hows you doing?

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

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

ManyThanks
MCN(Si)

By Datasource, do you mean the
"CJ Taylor" <no****@blowgoats.com> wrote in message
news:10*************@corp.supernews.com...
If they are associated with the same currency manager it will do it
automatically.

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

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

so the best way to handle this is.

In your class delcaration do this...

Private WithEvents _cmMyDataset as CurrencyManager

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

_cmMyDataSet = BindingContext(myDataSource, "myDataTable")

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

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

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

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

HTH,
CJ

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

Sorry but i`ve been searching everywhere for this even went out and bought
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


Nov 20 '05 #3
Simon,

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

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

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

How are things? Things are busy as sh**

=)

-CJ

"MadCrazyNewbie" <te**@nospam.com> wrote in message
news:Dc********************@karoo.co.uk...
Hey CJ,

Hows you doing?

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

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

ManyThanks
MCN(Si)

By Datasource, do you mean the
"CJ Taylor" <no****@blowgoats.com> wrote in message
news:10*************@corp.supernews.com...
If they are associated with the same currency manager it will do it
automatically.

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

This CurrencyManager is automatically subscribed the the datagrid events

(or
vise versa, either way, upon changing the position in a datagrid (i.e

moving
to a new row) the currency managers position is changed for you and an

event
is fired.

so the best way to handle this is.

In your class delcaration do this...

Private WithEvents _cmMyDataset as CurrencyManager

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

_cmMyDataSet = BindingContext(myDataSource, "myDataTable")

Obviously replace those with valid values for your dataset and datatable.
Then, in your property browser on the top left (the drop down) you can

find
the variable _cmMyDataSet Variable and the events associated with it on

the
right.

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

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

HTH,
CJ

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

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

bought
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



Nov 20 '05 #4
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" <no****@blowgoats.com> wrote in message
news:10*************@corp.supernews.com...
Simon,

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

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

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

How are things? Things are busy as sh**

=)

-CJ

"MadCrazyNewbie" <te**@nospam.com> wrote in message
news:Dc********************@karoo.co.uk...
Hey CJ,

Hows you doing?

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

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

ManyThanks
MCN(Si)

By Datasource, do you mean the
"CJ Taylor" <no****@blowgoats.com> wrote in message
news:10*************@corp.supernews.com...
If they are associated with the same currency manager it will do it
automatically.

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

This CurrencyManager is automatically subscribed the the datagrid
events
(or
vise versa, either way, upon changing the position in a datagrid (i.e

moving
to a new row) the currency managers position is changed for you and an

event
is fired.

so the best way to handle this is.

In your class delcaration do this...

Private WithEvents _cmMyDataset as CurrencyManager

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

_cmMyDataSet = BindingContext(myDataSource, "myDataTable")

Obviously replace those with valid values for your dataset and

datatable.
Then, in your property browser on the top left (the drop down) you can

find
the variable _cmMyDataSet Variable and the events associated with it on the
right.

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

CurrencyMangers are also INCREDIBLY useful when doing record

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

HTH,
CJ

"MadCrazyNewbie" <te**@nospam.com> wrote in message
news:yG********************@karoo.co.uk...
> Hey Group,
>
> Sorry but i`ve been searching everywhere for this even went out and

bought
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
>
>



Nov 20 '05 #5
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" <te**@nospam.com> wrote in message
news:iv********************@karoo.co.uk...
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" <no****@blowgoats.com> wrote in message
news:10*************@corp.supernews.com...
Simon,

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

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

click it (subscribing to it) and then that is your notifcation that the

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

How are things? Things are busy as sh**

=)

-CJ

"MadCrazyNewbie" <te**@nospam.com> wrote in message
news:Dc********************@karoo.co.uk...
Hey CJ,

Hows you doing?

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

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

ManyThanks
MCN(Si)

By Datasource, do you mean the
"CJ Taylor" <no****@blowgoats.com> wrote in message
news:10*************@corp.supernews.com...
> If they are associated with the same currency manager it will do it
> automatically.
>
> However, the probably isn't the case. anyways, in ADO.NET you have

these
> things called CurrencyManagers that basically act kinda like an old
> ADODB.Recordset (yes like many things in .NET). Anyways,

CurrencyManagers
> are created from bindings (actually you get them from the bindingContext of
> the control).
>
> This CurrencyManager is automatically subscribed the the datagrid events (or
> vise versa, either way, upon changing the position in a datagrid (i.e moving
> to a new row) the currency managers position is changed for you and an event
> is fired.
>
> so the best way to handle this is.
>
> In your class delcaration do this...
>
> Private WithEvents _cmMyDataset as CurrencyManager
>
> Then in your form load (best place I think, you can do it others like in
> your constructor, but not really a big deal.
>
> _cmMyDataSet = BindingContext(myDataSource, "myDataTable")
>
> Obviously replace those with valid values for your dataset and

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

on the
> right.
>
> Subscribe to the PositionChanged event, and then you can do whatever you > want. (i.e something with your combobox based on new row data).
>
> CurrencyMangers are also INCREDIBLY useful when doing record

manipulation,
> because you can actually turn off the binding using the

.SuspendBinding()
> and .ResumeBinding() methods, so if your working with large lists (i.e. > filling a large dataset) you can use suspendbinding while your filling it
> (otherwise, every time an item is added it goes through the process
of > repainting a control because of the ListChanged event on an

IListSource > item.
>
> HTH,
> CJ
>
>
>
>
>
> "MadCrazyNewbie" <te**@nospam.com> wrote in message
> news:yG********************@karoo.co.uk...
> > Hey Group,
> >
> > Sorry but i`ve been searching everywhere for this even went out and bought
> 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
> >
> >
>
>



Nov 20 '05 #6
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" <no****@blowgoats.com> wrote in message
news:10*************@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. look there. =)


"MadCrazyNewbie" <te**@nospam.com> wrote in message
news:iv********************@karoo.co.uk...
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" <no****@blowgoats.com> wrote in message
news:10*************@corp.supernews.com...
Simon,

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

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

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

How are things? Things are busy as sh**

=)

-CJ

"MadCrazyNewbie" <te**@nospam.com> wrote in message
news:Dc********************@karoo.co.uk...
> Hey CJ,
>
> Hows you doing?
>
> Right i`ve added Private WithEvents cmDsAccess As CurrencyManager in my > Class Decleration and then added cmDsAccess =

BindingContext(objdsAccess,
> "Users") in my form load.
>
> How would i now get it to change my bindings on my textboxs, and
Combo box
> as i select rows in my Datagrid?
>
> ManyThanks
> MCN(Si)
>
> By Datasource, do you mean the
> "CJ Taylor" <no****@blowgoats.com> wrote in message
> news:10*************@corp.supernews.com...
> > If they are associated with the same currency manager it will do
it > > automatically.
> >
> > However, the probably isn't the case. anyways, in ADO.NET you have these
> > things called CurrencyManagers that basically act kinda like an old > > ADODB.Recordset (yes like many things in .NET). Anyways,
CurrencyManagers
> > are created from bindings (actually you get them from the

bindingContext
> of
> > the control).
> >
> > This CurrencyManager is automatically subscribed the the datagrid

events
> (or
> > vise versa, either way, upon changing the position in a datagrid

(i.e > moving
> > to a new row) the currency managers position is changed for you and an
> event
> > is fired.
> >
> > so the best way to handle this is.
> >
> > In your class delcaration do this...
> >
> > Private WithEvents _cmMyDataset as CurrencyManager
> >
> > Then in your form load (best place I think, you can do it others like
in
> > your constructor, but not really a big deal.
> >
> > _cmMyDataSet = BindingContext(myDataSource, "myDataTable")
> >
> > Obviously replace those with valid values for your dataset and
datatable.
> >
> > Then, in your property browser on the top left (the drop down) you
can > find
> > the variable _cmMyDataSet Variable and the events associated with
it on
> the
> > right.
> >
> > Subscribe to the PositionChanged event, and then you can do
whatever you
> > want. (i.e something with your combobox based on new row data).
> >
> > CurrencyMangers are also INCREDIBLY useful when doing record
manipulation,
> > because you can actually turn off the binding using the
.SuspendBinding()
> > and .ResumeBinding() methods, so if your working with large lists

(i.e.
> > filling a large dataset) you can use suspendbinding while your filling it
> > (otherwise, every time an item is added it goes through the
process of > > repainting a control because of the ListChanged event on an

IListSource
> > item.
> >
> > HTH,
> > CJ
> >
> >
> >
> >
> >
> > "MadCrazyNewbie" <te**@nospam.com> wrote in message
> > news:yG********************@karoo.co.uk...
> > > Hey Group,
> > >
> > > Sorry but i`ve been searching everywhere for this even went out and > bought
> > 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
> > >
> > >
> >
> >
>
>



Nov 20 '05 #7
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" <te**@nospam.com> wrote in message
news:u7********************@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 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" <no****@blowgoats.com> wrote in message
news:10*************@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. look

there.
=)


"MadCrazyNewbie" <te**@nospam.com> wrote in message
news:iv********************@karoo.co.uk...
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" <no****@blowgoats.com> wrote in message
news:10*************@corp.supernews.com...
> Simon,
>
> since you declared your cmDsAccess WithEvents you can look up in the top > left dropdown where it describes all you objects etc (like textboxes and so
> on).
>
> in there you will see your cmDsAccess object. If you click on it,

you'll
> see the events on the right side combo box. One of those will be

position
> changed.
>
> click it (subscribing to it) and then that is your notifcation that the row
> position has changed within your datagrid. At that point, you can do > whatever you want. for exmaple, on your position chaged event you can
get
> the current row from the currency manager (cmDsAccess.Current()) and
> maniuplate your combo boxes based off that.
>
> How are things? Things are busy as sh**
>
> =)
>
> -CJ
>
> "MadCrazyNewbie" <te**@nospam.com> wrote in message
> news:Dc********************@karoo.co.uk...
> > Hey CJ,
> >
> > Hows you doing?
> >
> > Right i`ve added Private WithEvents cmDsAccess As CurrencyManager
in
my
> > Class Decleration and then added cmDsAccess =
BindingContext(objdsAccess,
> > "Users") in my form load.
> >
> > How would i now get it to change my bindings on my textboxs, and Combo box
> > as i select rows in my Datagrid?
> >
> > ManyThanks
> > MCN(Si)
> >
> > By Datasource, do you mean the
> > "CJ Taylor" <no****@blowgoats.com> wrote in message
> > news:10*************@corp.supernews.com...
> > > If they are associated with the same currency manager it will do it > > > automatically.
> > >
> > > However, the probably isn't the case. anyways, in ADO.NET you have > these
> > > things called CurrencyManagers that basically act kinda like an old > > > ADODB.Recordset (yes like many things in .NET). Anyways,
> CurrencyManagers
> > > are created from bindings (actually you get them from the
bindingContext
> > of
> > > the control).
> > >
> > > This CurrencyManager is automatically subscribed the the
datagrid events
> > (or
> > > vise versa, either way, upon changing the position in a datagrid

(i.e
> > moving
> > > to a new row) the currency managers position is changed for you

and
an
> > event
> > > is fired.
> > >
> > > so the best way to handle this is.
> > >
> > > In your class delcaration do this...
> > >
> > > Private WithEvents _cmMyDataset as CurrencyManager
> > >
> > > Then in your form load (best place I think, you can do it others

like
in
> > > your constructor, but not really a big deal.
> > >
> > > _cmMyDataSet = BindingContext(myDataSource, "myDataTable")
> > >
> > > Obviously replace those with valid values for your dataset and
> datatable.
> > >
> > > Then, in your property browser on the top left (the drop down) you can
> > find
> > > the variable _cmMyDataSet Variable and the events associated
with it on
> > the
> > > right.
> > >
> > > Subscribe to the PositionChanged event, and then you can do whatever you
> > > want. (i.e something with your combobox based on new row data).
> > >
> > > CurrencyMangers are also INCREDIBLY useful when doing record
> manipulation,
> > > because you can actually turn off the binding using the
> .SuspendBinding()
> > > and .ResumeBinding() methods, so if your working with large
lists (i.e.
> > > filling a large dataset) you can use suspendbinding while your filling
> it
> > > (otherwise, every time an item is added it goes through the

process
of
> > > repainting a control because of the ListChanged event on an
IListSource
> > > item.
> > >
> > > HTH,
> > > CJ
> > >
> > >
> > >
> > >
> > >
> > > "MadCrazyNewbie" <te**@nospam.com> wrote in message
> > > news:yG********************@karoo.co.uk...
> > > > Hey Group,
> > > >
> > > > Sorry but i`ve been searching everywhere for this even went out and
> > bought
> > > 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
> > > >
> > > >
> > >
> > >
> >
> >
>
>



Nov 20 '05 #8
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" <no****@blowgoats.com> wrote in message
news:10*************@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 to it,
makes things easier. Is your datagrid bound to this datatable on the
objDsAccess? what table is it bound to?

"MadCrazyNewbie" <te**@nospam.com> wrote in message
news:u7********************@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 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" <no****@blowgoats.com> wrote in message
news:10*************@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. look there.
=)


"MadCrazyNewbie" <te**@nospam.com> wrote in message
news:iv********************@karoo.co.uk...
> 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" <no****@blowgoats.com> wrote in message
> news:10*************@corp.supernews.com...
> > Simon,
> >
> > since you declared your cmDsAccess WithEvents you can look up in the top
> > left dropdown where it describes all you objects etc (like
textboxes and
> so
> > on).
> >
> > in there you will see your cmDsAccess object. If you click on it,
you'll
> > see the events on the right side combo box. One of those will be
position
> > changed.
> >
> > click it (subscribing to it) and then that is your notifcation
that the
> row
> > position has changed within your datagrid. At that point, you can do > > whatever you want. for exmaple, on your position chaged event you can get
> > the current row from the currency manager (cmDsAccess.Current())
and > > maniuplate your combo boxes based off that.
> >
> > How are things? Things are busy as sh**
> >
> > =)
> >
> > -CJ
> >
> > "MadCrazyNewbie" <te**@nospam.com> wrote in message
> > news:Dc********************@karoo.co.uk...
> > > Hey CJ,
> > >
> > > Hows you doing?
> > >
> > > Right i`ve added Private WithEvents cmDsAccess As CurrencyManager in my
> > > Class Decleration and then added cmDsAccess =
> BindingContext(objdsAccess,
> > > "Users") in my form load.
> > >
> > > How would i now get it to change my bindings on my textboxs, and

Combo
> box
> > > as i select rows in my Datagrid?
> > >
> > > ManyThanks
> > > MCN(Si)
> > >
> > > By Datasource, do you mean the
> > > "CJ Taylor" <no****@blowgoats.com> wrote in message
> > > news:10*************@corp.supernews.com...
> > > > If they are associated with the same currency manager it will
do it
> > > > automatically.
> > > >
> > > > However, the probably isn't the case. anyways, in ADO.NET you

have
> > these
> > > > things called CurrencyManagers that basically act kinda like
an old
> > > > ADODB.Recordset (yes like many things in .NET). Anyways,
> > CurrencyManagers
> > > > are created from bindings (actually you get them from the
> bindingContext
> > > of
> > > > the control).
> > > >
> > > > This CurrencyManager is automatically subscribed the the datagrid > events
> > > (or
> > > > vise versa, either way, upon changing the position in a
datagrid (i.e
> > > moving
> > > > to a new row) the currency managers position is changed for you and
an
> > > event
> > > > is fired.
> > > >
> > > > so the best way to handle this is.
> > > >
> > > > In your class delcaration do this...
> > > >
> > > > Private WithEvents _cmMyDataset as CurrencyManager
> > > >
> > > > Then in your form load (best place I think, you can do it
others like
> in
> > > > your constructor, but not really a big deal.
> > > >
> > > > _cmMyDataSet = BindingContext(myDataSource, "myDataTable")
> > > >
> > > > Obviously replace those with valid values for your dataset and
> > datatable.
> > > >
> > > > Then, in your property browser on the top left (the drop down)

you can
> > > find
> > > > the variable _cmMyDataSet Variable and the events associated with
it
> on
> > > the
> > > > right.
> > > >
> > > > Subscribe to the PositionChanged event, and then you can do

whatever
> you
> > > > want. (i.e something with your combobox based on new row data). > > > >
> > > > CurrencyMangers are also INCREDIBLY useful when doing record
> > manipulation,
> > > > because you can actually turn off the binding using the
> > .SuspendBinding()
> > > > and .ResumeBinding() methods, so if your working with large

lists > (i.e.
> > > > filling a large dataset) you can use suspendbinding while your
filling
> > it
> > > > (otherwise, every time an item is added it goes through the

process
of
> > > > repainting a control because of the ListChanged event on an
> IListSource
> > > > item.
> > > >
> > > > HTH,
> > > > CJ
> > > >
> > > >
> > > >
> > > >
> > > >
> > > > "MadCrazyNewbie" <te**@nospam.com> wrote in message
> > > > news:yG********************@karoo.co.uk...
> > > > > Hey Group,
> > > > >
> > > > > Sorry but i`ve been searching everywhere for this even went out and
> > > bought
> > > > 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
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
>



Nov 20 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Nakor | last post by:
Hello, I am a Computer Programmer Analyst student. I am taking this course which for this week's assignment requires me to join some newsgroups. I am sorry to have to spam you with such useless...
0
by: Marco Herrn | last post by:
Hi, I tried to install a package under debian, where in the postinstall phase some python scripts are called. Then I got the error "Sorry invalid mode: U". I looked what this script does and it...
8
by: Ivan Paganini | last post by:
Sorry, and thanks for the help. I will be more carefull in the next time. Ivan S>P<M
354
by: Montrose... | last post by:
After working in c# for a year, the only conclusion I can come to is that I wish I knew c. All I need is Linux, the gnu c compiler and I can do anything. Web services are just open sockets...
5
by: Nitin Bhardwaj | last post by:
Sorry I made a typo in the code The correct one is like this : #include <stdio.h> int main(void) { int *buf1 = malloc(10*sizeof(int)); int *buf2 = malloc(10*sizeof(int)); printf(buf1 >...
3
by: Wizard | last post by:
Hi All, Sorry for been a pain in the ass, but im looking everywhere and can't seem to find the answers. I would like to build a small ASP based site. I have 4 departments, and what i would...
0
by: Carlo, MCP | last post by:
Sorry for the Italian previous message. It was a sending mistake. Sorry again. C.
8
by: anand.1783 | last post by:
Dear moderator, Sorry for the inconvinience. So I am really sorry for the mistake. It happend by mistake and it will not be repeated. so kindly consider my Apology. Anand.
1
by: maya | last post by:
I have a quick HomeSite question.. sorry, my news server doesn't carry HomeSite ng... I just need to know how to switch from generating special chars (called "entities" in XML) with numbers...
7
by: JamesCX DiPietro | last post by:
I just wanted to apologize again to Mr. Stuckle and Mr. Fesser for my awful and despicable behavior. THey were right all along and I behaved like a total shithead. I'm sorry, and I will never try...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.