sandra1628
asked on
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 BindingNavigatorMoveNextIt em_Click(B yVal sender As System.Object, ByVal e As System.EventArgs) Handles BindingNavigatorMoveNextIt em.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.T oString)
MsgBox("Move next - Is date null? " + IsDBNull(dateValue).ToStri ng)
If IsDBNull(dateValue) Then
Me.DateDateTimePicker.Valu e = Date.Now
Me.DateDateTimePicker.Chec ked = False
Else
Me.DateDateTimePicker.Valu e = dateValue
Me.DateDateTimePicker.Chec ked = 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?
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 BindingNavigatorMoveNextIt
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.T
MsgBox("Move next - Is date null? " + IsDBNull(dateValue).ToStri
If IsDBNull(dateValue) Then
Me.DateDateTimePicker.Valu
Me.DateDateTimePicker.Chec
Else
Me.DateDateTimePicker.Valu
Me.DateDateTimePicker.Chec
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?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
it works great, thanks
ASKER