R
Rob W
Greetings,
My notepad application create a new instance of a form for a MDI
application.
The code below create a new instance of form "text document" and creates a
menu item in the file menu strip option and assigns all new menu items to a
single event handler "documentToolStripMenuItem".
The plan was to use the sender property of the new created menustrip item to
switch between forms, with the selected menu item becoming the active form.
I've been looking at Ctype and Directcast and can't see how I can use a
property of type object to be used to pass in the form name or be converted
to type of form.
Document.Active()
(sender).Active()
Hope this is understandable, can anyone suggest a way forward?
In the mean time I am going to take a break then re-visit it.
Thanks
Rob
Private Sub NewCtrlNToolStripMenuItem_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles NewCtrlNToolStripMenuItem.Click,
NewToolStripButton.Click
Dim MDIChildForm As New textdocument()
MDIChildForm.MdiParent = Me
MDIChildForm.Text = "Document" & Me.MdiChildren.GetLength(0) 'Set document
title based on document number
MDIChildForm.Show()
'Add new menu item for each document opened
Dim FileNewMenuItem As New ToolStripMenuItem("Document" &
Me.MdiChildren.GetLength(0), Nothing, New EventHandler(AddressOf
documentToolStripMenuItem_Click))
FileToolStripMenuItem.DropDownItems.Add(FileNewMenuItem)
My notepad application create a new instance of a form for a MDI
application.
The code below create a new instance of form "text document" and creates a
menu item in the file menu strip option and assigns all new menu items to a
single event handler "documentToolStripMenuItem".
The plan was to use the sender property of the new created menustrip item to
switch between forms, with the selected menu item becoming the active form.
I've been looking at Ctype and Directcast and can't see how I can use a
property of type object to be used to pass in the form name or be converted
to type of form.
Document.Active()
(sender).Active()
Hope this is understandable, can anyone suggest a way forward?
In the mean time I am going to take a break then re-visit it.
Thanks
Rob
Private Sub NewCtrlNToolStripMenuItem_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles NewCtrlNToolStripMenuItem.Click,
NewToolStripButton.Click
Dim MDIChildForm As New textdocument()
MDIChildForm.MdiParent = Me
MDIChildForm.Text = "Document" & Me.MdiChildren.GetLength(0) 'Set document
title based on document number
MDIChildForm.Show()
'Add new menu item for each document opened
Dim FileNewMenuItem As New ToolStripMenuItem("Document" &
Me.MdiChildren.GetLength(0), Nothing, New EventHandler(AddressOf
documentToolStripMenuItem_Click))
FileToolStripMenuItem.DropDownItems.Add(FileNewMenuItem)