Solved

Customized BindingNavigatorMoveNextItem.Click in vb .net

Posted on 2013-10-22
3
1,294 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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 …
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

759 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

Need Help in Real-Time?

Connect with top rated Experts

26 Experts available now in Live!

Get 1:1 Help Now