By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,275 Members | 936 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,275 IT Pros & Developers. It's quick & easy.

Sorry to Re-Post - Databindings problem

P: n/a
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
Share this Question
Share on Google+
8 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.