Thread: Question Choose the right start?
View Single Post
  #7 (permalink)  
Old 07-11-2009, 3:41 AM
cjard's Avatar
cjard cjard is offline
VB.NET Forum All-Mighty
.NET Framework: .NET 2.0 (VS 2005)
 
Join Date: Apr 2006
Age: 65
Posts: 6,442
Reputation: 807
cjard has a reputation beyond reputecjard has a reputation beyond reputecjard has a reputation beyond reputecjard has a reputation beyond reputecjard has a reputation beyond reputecjard has a reputation beyond reputecjard has a reputation beyond reputecjard has a reputation beyond reputecjard has a reputation beyond reputecjard has a reputation beyond reputecjard has a reputation beyond repute
Default

Quote:
Originally Posted by thek View Post
Yes.

But there is no code behind the BindingNavigatorMoveNextItem_Click, it looks like this:

Code:
Private Sub BindingNavigatorMoveNextItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BindingNavigatorMoveNextItem.Click

    End Sub
Where can I see the code that move one record forward? (When I create database access via the wizard)

To say John's post another way:

You can't see it, because Microsoft wrote the BindingNavigator. It takes in a BindingSource as a parameter, and then simply calls bindingSource.MoveNext every time you click on what it knows to be the Next button (you tell it that too)

Simply put, their code might look like this:

Code:
Class BindingNavigator
  
  Private _bs as BindingSource
  Property BindSource as BindingSource
    Set
      _bs = value
    End Set
  End Property

  Private _mni as Button
  Property MoveNextItem as Button
    Set
      _mni = value
      AddHandler(_mni.Click, AddressOf(MNIClickHandler))
    End Set
  End Property

  Private Sub MNIClickHandler
    _bs.MoveNext()
  End Sub
End Class
If you really wanna see the code then use Reflector to decompile the .NET framework, but it will be like this in essence:
When the MoveNextItem is set to a button, the click handler of that button is assigned INSIDE the bindingnavigator code to a handler that is ALSO inside the bindingnavigator code
Every time you click the button, it just calls MoveNext on the bindingsource the bindingnavigator is attached to (ALSO inside the bindingnavigator code)

If you want to "roll your own" MoveNext handler you HAVE to tell the BindingNavigator it has no set MoveNextItem
-> Open the properties for the BindingNavigator
Find the MoveNextItem setting
Set it to NONE

Now you can roll your own click handler in your own code
__________________
DW1 DW2 DW3 DW4 DNU PQ
Reply With Quote