How to get/ override usercontrol methods.

  • Thread starter Thread starter Syed Zaidi
  • Start date Start date
S

Syed Zaidi

Hello All
I am a newbie in VB.NET and wanting to create a toolbar(User Control) for Database Navigation. What exactly I want is to have a user control which is inherited from the system.windows.forms. usercontrol and contain a toolbar which have buttons for navigating records. And the client Windows Form which owns that control must overrides the navigation methods of user control. Forexample to add some custom functionality for moving to first record.
Kind Regards
Syed Zaidi

From http://www.developmentnow.com/g/38_2003_11_0_0_0/dotnet-languages-vb.htm

Posted via DevelopmentNow.com Groups
http://www.developmentnow.com
 
I would do something like the following (syntax is not guaranteed perfect):

On you UserControl, drop four buttons, lay them out how you want, and name
one btnFirst, btnPrev, btnNext, and btnLast.

Then in the code behind code as follows (Designer generated code left out):

Public Class MyNavControl
Inherits UserControl

Public Enum MovementStep
First
Previous
Next
Last
End Enum

Public Event Navigate(WhichWay As MovementStep)

Public Sub btnClick(sender As Object, e As EventArgs) _
Handles btnFirst.Click, btnPrev.Click, btnNext.Click, btnLast.Click
If sender Is btnFirst Then
RaiseEvent Navigate(MovementStep.First)

ElseIf sender Is btnPrev Then
RaiseEvent Navigate(MovementStep.Previous)

ElseIf sender Is btnNext Then
RaiseEvent Navigate(MovementStep.Next)

ElseIf sender Is btnLast Then
RaiseEvent Navigate(MovementStep.Last)

End If
End Sub
End Class
 
Back
Top