Solved

Customized BindingNavigatorMoveNextItem.Click in vb .net

Posted on 2013-10-22
3
1,348 Views
Last Modified: 2013-10-23
I want to check some conditions when user clicking the 'move next' button from the Binding Navigator.

My problem is when I retreive the current binding source item, it is the previous record,  I would like to get the record that are going to display on the form when the "move next" button is clicking.

Here is my code:

Private Sub BindingNavigatorMoveNextItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BindingNavigatorMoveNextItem.Click

        Dim currentRow As DataRowView = Me.MyBindingSource.Current

        Dim dateValue As Date = currentRow.Item("Date")

        MsgBox("Move next - date is " + dateValue)

        MsgBox("Move next - Current binding position is " + MyBindingSource.Position.ToString)
   
        MsgBox("Move next - Is date null? " + IsDBNull(dateValue).ToString)

        If IsDBNull(dateValue) Then
           
            Me.DateDateTimePicker.Value = Date.Now
            Me.DateDateTimePicker.Checked = False

        Else
            Me.DateDateTimePicker.Value = dateValue
            Me.DateDateTimePicker.Checked = True
        End If

    End Sub

When running the code, when I clicks the 'move next' button from the binding navigator bar, the current binding date and the current binding position is from the first record.  

How can I get the data for 2nd record instead?
0
Comment
Question by:sandra1628
  • 2
3 Comments
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 500 total points
ID: 39592661
You can replace


Dim currentRow As DataRowView = Me.MyBindingSource.Current

With

Dim currentRow As DataRowView = Me.MyBindingSource.Item(Me.MyBindingSource.Position + 1)


And wrap all the code in method in following condition

If Me.MyBindingSource.Position + 1 < Me.MyBindingSource.Count Then
0
 

Author Comment

by:sandra1628
ID: 39593999
It works great!  Thanks a lot !
0
 

Author Closing Comment

by:sandra1628
ID: 39594003
it works great, thanks
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question