Back and Forward.

  • Thread starter Thread starter Tracey
  • Start date Start date
T

Tracey

Hi, guys.
My application requires functionalities like back and
forward navigating button on winforms. And there are
many forms linking each other. Each form has a pair of
buttons of "Back" and "Forward "How can I implement the
back and forward procedure to make them work ?

Is there anyone has the same experience like that ?

Thanks
 
Hello,

Tracey said:
My application requires functionalities like back and
forward navigating button on winforms. And there are
many forms linking each other. Each form has a pair of
buttons of "Back" and "Forward "How can I implement the
back and forward procedure to make them work ?

You can create multiple usercontrols, one for each page, and show only the
active page. Maybe you can provide more details on where to navigate
forward and backward.
 
Hi, guys.
My application requires functionalities like back and
forward navigating button on winforms. And there are
many forms linking each other. Each form has a pair of
buttons of "Back" and "Forward "How can I implement the
back and forward procedure to make them work ?

Is there anyone has the same experience like that ?

I have a template form which has the forward/back button, and items that
are global for all pages. I have a User control for each "page" with the
appropriate layout. I swap the User control when the user presses
forward/backward.

As for storing options, I have a class object in the template form that
stores the pertinent options for each page. The object is passed into the
constructor of the user controls. The user control populates the selected
options if the user is viewing a previous page. I'm still working on this
part though.

If anyone has done this before, I would like to know how you did it as
well. Thanks!
 
Navigation of forms can be very easily and effectively achieved creating a
Navigator Class that maintains the navigation path and also keeps track of
the current form. When the user clicks on forward or backward, you just call
the Navigator's Next/Previous methods.
 
Navigation of forms can be very easily and effectively achieved creating a
Navigator Class that maintains the navigation path and also keeps track of
the current form. When the user clicks on forward or backward, you just call
the Navigator's Next/Previous methods.
 
Hello,

Tracey said:
My application requires functionalities like back and
forward navigating button on winforms. And there are
many forms linking each other. Each form has a pair of
buttons of "Back" and "Forward "How can I implement the
back and forward procedure to make them work ?

You can create multiple usercontrols, one for each page, and show only the
active page. Maybe you can provide more details on where to navigate
forward and backward.
 
Tracey,

I have navigation(First,Previous,Next,Last) and command
buttons(Add,Update,Delete,Close) on a MDI Parent that control the actions of
the MDI children.

First I use a "Generic" form

Public Class A
Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

Public Sub New()
MyBase.New()

'This call is required by the Windows Form Designer.
InitializeComponent()

'Add any initialization after the InitializeComponent() call

End Sub

'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub

'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer

'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()
components = New System.ComponentModel.Container
End Sub

Public Overridable WriteOnly Property Navigate()
Set(ByVal Value)
Select Case Value
Case "Print"
Case "First"
Case "Previous"
Case "Next"
Case "Last"
Case "Add"
Case "Update"
Case "Delete"
Case "Close"
Case "Save"
End Select
End Set
End Property

#End Region

End Class

Then I derive all my MDI children from the above class.

Public Class frmRate
Inherits A

THE FOLLOWING PROPERTY IS USED BY MDI PARENT TO SEND COMMAND FROM TOOLBAR TO
CHILDREN

Public Overrides WriteOnly Property Navigate()
Set(ByVal Value)
Select Case Value
Case "Print"
Case "First"
Me.BindingContext(dsDataSet, "Ratefil").Position =
Me.BindingContext(dsDataSet).Position.MinValue
Case "Previous"
Me.BindingContext(dsDataSet, "Ratefil").Position -= 1
Case "Next"
Me.BindingContext(dsDataSet, "Ratefil").Position += 1
Case "Last"
Me.BindingContext(dsDataSet, "Ratefil").Position =
Me.BindingContext(dsDataSet).Position.MaxValue
Case "Add"
btAdd_Click("", System.EventArgs.Empty)
Case "Update"
btUpdate_Click("", System.EventArgs.Empty)
Case "Delete"
btDelete_Click("", System.EventArgs.Empty)
Case "Close"
End Select
End Set
End Property

In my MDI Parent this Sub is used to send messages to the MDI Children.

Private Sub ToolBar1_ButtonClick(ByVal sender As System.Object, ByVal e
As System.Windows.Forms.ToolBarButtonClickEventArgs) Handles
ToolBar1.ButtonClick
Try
Dim activeChild As Form = Me.ActiveMdiChild
If ActForm <> -1 Then
DirectCast(activeChild, A).Navigate =
e.Button.Text.ToString
End If
Catch ex As Exception
MessageBox.Show(ex.Source.ToString & " - " & ex.Message,
Application.ProductName, _
MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub

Hope this help. If this works thank Herfried he helped me with
ToolBar1_ButtonClick and "Generic" form code.

Ken
 
Thanks for your advice.
THe winforms in my application already have button
controls on each form, say "Back" and "Forward".

My winform have multiple links to other forms. And link
in other forms will also link to this form.

did I provide enough information ?
 
Thanks, Ken.
But my application is not a MDI Form application.

I got something useful from your code.
Thanks again!

-----Original Message-----
Tracey,

I have navigation(First,Previous,Next,Last) and command
buttons(Add,Update,Delete,Close) on a MDI Parent that control the actions of
the MDI children.

First I use a "Generic" form

Public Class A
Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

Public Sub New()
MyBase.New()

'This call is required by the Windows Form Designer.
InitializeComponent()

'Add any initialization after the InitializeComponent() call

End Sub

'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub

'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer

'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()
components = New System.ComponentModel.Container
End Sub

Public Overridable WriteOnly Property Navigate()
Set(ByVal Value)
Select Case Value
Case "Print"
Case "First"
Case "Previous"
Case "Next"
Case "Last"
Case "Add"
Case "Update"
Case "Delete"
Case "Close"
Case "Save"
End Select
End Set
End Property

#End Region

End Class

Then I derive all my MDI children from the above class.

Public Class frmRate
Inherits A

THE FOLLOWING PROPERTY IS USED BY MDI PARENT TO SEND COMMAND FROM TOOLBAR TO
CHILDREN

Public Overrides WriteOnly Property Navigate()
Set(ByVal Value)
Select Case Value
Case "Print"
Case "First"
Me.BindingContext
(dsDataSet, "Ratefil").Position =
Me.BindingContext(dsDataSet).Position.MinValue
Case "Previous"
Me.BindingContext
(dsDataSet, "Ratefil").Position -= 1
Case "Next"
Me.BindingContext
(dsDataSet, "Ratefil").Position += 1
Case "Last"
Me.BindingContext
(dsDataSet, "Ratefil").Position =
 
Back
Top