How to get/ override usercontrol methods.

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
 
A

Arthur Dent

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top