Customized BindingNavigatorMoveNextItem.Click in vb .net
Posted on 2013-10-22
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
Me.DateDateTimePicker.Value = dateValue
Me.DateDateTimePicker.Checked = True
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?