PictureBox error when Form_Activated is fired
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:
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim bRet As Boolean
Dim myimg As Image
Dim sAppName As String
Dim sLogo As String
Try
myimg = New Bitmap("C:\Program Files\Common Files\Microsoft Shared\Clipart\cagcat50\BD06675_.WMF")
picLogo.SizeMode = PictureBoxSizeMode.AutoSize
picLogo.Image = CType(myimg, Image)
picLogo.Refresh()
Catch ex1 As Exception
MessageBox.Show(ex1.ToString())
Finally
If Not IsNothing(myimg) Then
myimg.Dispose()
myimg = Nothing
End If
End Try
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