Hi

I am getting an error when I minimize and maximize a form where I dynamically load a picture box. Here's the code:

VB Code:
  1. Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
  2.         Dim bRet As Boolean
  3.         Dim myimg As Image
  4.         Dim sAppName As String
  5.         Dim sLogo As String
  6.  
  7.         Try
  8.  
  9.             myimg = New Bitmap("C:\Program Files\Common Files\Microsoft Shared\Clipart\cagcat50\BD06675_.WMF")
  10.             picLogo.SizeMode = PictureBoxSizeMode.AutoSize
  11.             picLogo.Image = CType(myimg, Image)
  12.             picLogo.Refresh()
  13.  
  14.         Catch ex1 As Exception
  15.             MessageBox.Show(ex1.ToString())
  16.         Finally
  17.             If Not IsNothing(myimg) Then
  18.                 myimg.Dispose()
  19.                 myimg = Nothing
  20.             End If
  21.         End Try
  22.  
  23.     End Sub

Before I load the image by clicking the button I can minimize and maximize my form. However, when I load the image in the picturebox, minimize the form and maximize I get the following error popping up:


An unhandled exception of type 'System.ArgumentException' occurred in system.windows.forms.dll

Additional information: Invalid parameter used


I get a much longer error message when running the compiled code.

Can anyone help please.

Thanks