?
Solved

Don't know how to Declare 'LoadPicture'

Posted on 2005-04-05
5
Medium Priority
?
509 Views
Last Modified: 2012-06-27
I'm trying to load a picture during a MouseOver event, but it's saying that I need to declare 'LoadPicture'.  I'm using .NET and I'm in a Public Class and created the following Sub:

Private Sub picConversion_MouseOver(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles picConversion.Click

        Dim picRVDescriptions As New PictureBox
        picRVDescriptions.Image = LoadPicture("C:\RADIISNT\Radiis Pictures\ClassC Desc.jpg")

    End Sub

But it says "Name 'LoadPicture' is not declared"

Can anyone help?
0
Comment
Question by:RAMCIT
  • 3
  • 2
5 Comments
 
LVL 32

Expert Comment

by:Erick37
ID: 13710803
picRVDescriptions.Image = Image.FromFile("C:\RADIISNT\Radiis Pictures\ClassC Desc.jpg")
0
 

Author Comment

by:RAMCIT
ID: 13711203
I don't get any errors, but now nothing happens.  I made it a click-event just to see if it worked and no picture loads

Private Sub picClassC_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles picClassC.Click
        Dim picRVDescriptions As New PictureBox
        picRVDescriptions.Image = Image.FromFile("C:\RADIIS NT\RADIIS Pictures\ClassCDesc.jpg")
    End Sub

Any Ideas?
0
 
LVL 32

Accepted Solution

by:
Erick37 earned 2000 total points
ID: 13711265
If you want to add the control at run-time, you will need to do a few mort things:

        Dim picRVDescriptions As New PictureBox
        picRVDescriptions.Location = New System.Drawing.Point(0, 0)
        picRVDescriptions.Name = "picRVDescriptions"
        picRVDescriptions.Size = New System.Drawing.Size(200, 200)
        picRVDescriptions.Visible = True
        Controls.Add(picRVDescriptions)

        picRVDescriptions.Image = Image.FromFile("C:\RADIIS NT\RADIIS Pictures\ClassCDesc.jpg")

See:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vbCode/html/vbtskCodeAddingWindowsFormsControlAtRuntimeVisualBasic.asp
0
 

Author Comment

by:RAMCIT
ID: 13712424
Thanks for your help and I awarded you the points because I accomplished what you needed, but I need one more thing.

How do I get rid of the picture? or clear the picture, because I want that picture to change depending on what I click, but now it only stays on the first thing I click and the other clicks events either doon't work or it's placing the picture behind the first one and you can't see them.

Private Sub picClassA_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles picClassA.Click
        Dim picRVDescriptions As New PictureBox

        picRVDescriptions.Location = New System.Drawing.Point(256, 80)
        picRVDescriptions.Name = "picRVDescriptions"
        picRVDescriptions.Size = New System.Drawing.Size(304, 392)
        picRVDescriptions.Visible = True
        Controls.Add(picRVDescriptions)

        picRVDescriptions.Image = Image.FromFile("C:\RADIIS NT\RADIIS Pictures\picClassA.jpg")
    End Sub
0
 
LVL 32

Expert Comment

by:Erick37
ID: 13712449

' To clear the picturebox during run-time
If Not (picRVDescriptions.Image Is Nothing) Then
   picRVDescriptions.Image.Dispose()
   picRVDescriptions.Image = Nothing
End If

See:
Setting Pictures at Run Time (Windows Forms)
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/vbconresettingpicturesatruntime.asp
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Loops Section Overview
Suggested Courses

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question