Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1446
  • Last Modified:

Customized BindingNavigatorMoveNextItem.Click in vb .net

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
sandra1628
Asked:
sandra1628
  • 2
1 Solution
 
CodeCruiserCommented:
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
 
sandra1628Author Commented:
It works great!  Thanks a lot !
0
 
sandra1628Author Commented:
it works great, thanks
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now