Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PictureBox Image clear dispose remove release

Status
Not open for further replies.

lrfcbabe

Programmer
Jul 19, 2001
108
US
In the example below I want to clear the image in the PictureBox so I can rename it. PB1.image = Nothing does not work, dispose does not work. I get the exception "file in use by another program" when I try to rename it.

Private Sub btnRename_Click(sender As System.Object, e As System.EventArgs) Handles btnRename.Click
Dim i As Integer
Dim fname As String

If LB1.Items.Count > 0 Then
PB1.Image = Nothing
'PB1.Image.Dispose()
'PB1.Visible = False
For i = 0 To LB1.Items.Count - 1
fname = LB1.Items(i).ToString
If fname.Contains("%") Then
fname = fname.Replace("%", "")
If Not File.Exists(fname) Then
File.Move(FP & LB1.Items(i).ToString, FP & fname)
Application.DoEvents()
End If
End If
Next
isafile(FP)
'PB1.Visible = True
PB1.Image = Image.FromFile(FP & LB1.Items(i).ToString)
Transform()

End If

End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top