display pic in picbox

anodize

Newcomer
Joined
Jun 15, 2005
Messages
1
hi guys, i'm new here, i just tryin to create a simple form which i use it to view picture in a picture.. but i seem to have some prob with the coding for the displaying of image.. can someone help me pls.

Code:
Imports System.Drawing

Public Class Form2
    Inherits System.Windows.Forms.Form
    Friend WithEvents btnClose As System.Windows.Forms.Button
    Friend WithEvents PictureBox1 As System.Windows.Forms.PictureBox

    Private Sub btnBack_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBack.Click
        Dim firstform As New Form1
        Dim secondform As New Form2
        firstform = New Form1
        firstform.Show()
        Me.Close()
    End Sub


    Private Sub PictureBox1_ParentChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.ParentChanged
        
       Me.PictureBox1.Image = New Bitmap("C:\MyImage.bmp")

End Sub

End Class
 
Not entirely sure what you are trying to do here. What are each of the forms for in the above code?
Also I notice you create a new instance of Form2 from within Form2 and never use it while also assigning 2 new instances of Form1 to firstform.

If you just want to display a picture in a picturebox you could put the line
Visual Basic:
Me.PictureBox1.Image = New Bitmap("C:\MyImage.bmp")
into the Form's load event and it should display correctly.
 
Back
Top