?
Solved

Customized BindingNavigatorMoveNextItem.Click in vb .net

Posted on 2013-10-22
3
Medium Priority
?
1,413 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 2000 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

719 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