Newbie - Datagrid Binding Problem

W

Wizard

Hi There Thanks for Everyones Help So Far,

I used the Database Form Wizard and i`ve looked at he code from that. Its
working Great Now. Now the Only Problem I have is i`ve added a Datagrid to
my App Aswell, Makes it easier then clicking next a few hundred times to get
to the record I want. Ok I could just use a datagrid but it looks a lot
nicer if the Datagrid is there aswell. I`ve marked my Datagrid as Read only
and want the user to be able to click on the row they want and for that.
When I click on my Row on my datagrid is dosn`t update my Position_Changed
thinggy which tells them what record number there one.

Here is my Position Changed Code:

Private Sub dsSystemUsers_PositionChanged()
Me.lblNavLocation.Text = (((Me.BindingContext(dsSystemUsers,
"Passwords").Position + 1).ToString + " of ") +
Me.BindingContext(dsSystemUsers, "Passwords").Count.ToString)
End Sub

I take it I need to Add a Line for My Datagrid I just can`t find any info.
Anywhere on how to do it:( Anybody point me in the right Direction please?

Many Thanks
NSC
 
B

Bart Mermuys

Hi,

Wizard said:
Hi There Thanks for Everyones Help So Far,

I used the Database Form Wizard and i`ve looked at he code from that. Its
working Great Now. Now the Only Problem I have is i`ve added a Datagrid to
my App Aswell, Makes it easier then clicking next a few hundred times to
get to the record I want. Ok I could just use a datagrid but it looks a
lot nicer if the Datagrid is there aswell. I`ve marked my Datagrid as Read
only and want the user to be able to click on the row they want and for
that. When I click on my Row on my datagrid is dosn`t update my
Position_Changed thinggy which tells them what record number there one.

Here is my Position Changed Code:

Private Sub dsSystemUsers_PositionChanged()
Me.lblNavLocation.Text = (((Me.BindingContext(dsSystemUsers,
"Passwords").Position + 1).ToString + " of ") +
Me.BindingContext(dsSystemUsers, "Passwords").Count.ToString)
End Sub

I take it I need to Add a Line for My Datagrid I just can`t find any info.
Anywhere on how to do it:( Anybody point me in the right Direction please?

I assume that you have both controls (created by the wizard) and a DataGrid
(created by you), if the above code was from the wizard and you want the
grid and the controls to navigate together then set:
DataGrid1.DataSource to dsSystemUsers
DataGrid1.DataMember to "Passwords"

HTH,
Greetings
 
N

No_So_Clever

Hi,

Thnks for you help. I now have this code:

dgdSystemUsers.DataSource = dvSystemUsers
dgdSystemUsers.DataBindings.Add("Datasource", dvSystemUsers, "DepartmentID")
cmSystemUsers = DirectCast(BindingContext(dvSystemUsers), CurrencyManager)

and then my Postition_Changed Code:

Private Sub dsSystemUsers_PositionChanged()
Me.lblNavLocation.Text = (((cmSystemUsers.Position + 1).ToString + " of
") + cmSystemUsers.Count.ToString)
End Sub

I know there is something wong with this line:

dgdSystemUsers.DataBindings.Add("Datasource", dvSystemUsers,
"DepartmentID") - but I just don`t know what.

Also what else will I need to Add into my Position Changed code to get my
lblNavLocation.Text to update when i click on my datagrid?

Many Thanks in Advance
NSC
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top