Zebra0.com

visual-basic forms

A simpler way would be to add a new child when the open button is selected. If we do this we will not get an error, and we can get rid of the open menu item altogether. We will combine the code for ShowNewForm and OpenFile.
Private Sub OpenFile(ByVal sender As Object, ByVal e As EventArgs) _
   Handles OpenToolStripButton.Click
  Dim ChildForm As New Form1
  ChildForm.MdiParent = Me
  m_ChildFormNumber += 1
  ChildForm.Show()
  Dim OpenFileDialog As New OpenFileDialog
  OpenFileDialog.InitialDirectory = My.Computer.FileSystem.SpecialDirectories.MyDocuments
  OpenFileDialog.Filter = _
    "Picture Files (Bitmaps|*.bmp|GIFS|*.gif|JPG|*.jpg|All Files (*.*)|*.*"
  If (OpenFileDialog.ShowDialog(Me) = System.Windows.Forms.DialogResult.OK) Then
     Dim ActiveChild As Form1 = Me.ActiveMdiChild
     ChildForm.Text = OpenFileDialog.FileName
     ChildForm.Pic.Image = Image.FromFile(OpenFileDialog.FileName)
  End If
End Sub 'OpenFile
MDINotepad

NEXT: Form to Select Days