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