vb.net - FlowLayoutPanel remove background image and delete image file -


I am using the following code to remove all my controls inside FlowLayoutPanel:

  While Flow LayoutPanel 1 Control. Count & gt; 0 Dim controltoremove = FlowLayoutPanel1.Controls (0) FlowLayoutPanel1.Controls.Remove (controltoremove) controltoremove.Dispose () Application.DoEvents () to work in close while  

As it (I No one seems to see my control now inside my FlowLayoutPanel1 box), but once I get to this part of the code:

  My.Computer.FileSystem.DeleteFile ("C: \" WAMP \ www \ img \ "& Subitem (" id ") ToString.Replace (" "", "") and ".jpg")  

It tells me Is that image currently in use ?? ? Since I settled these controls (these images have been viewed as background image) should not I be able to remove the image file ??

I use this to create buttons inside the flowout panel:

  As an action in the form of an object for each subtitle New new image in the form of a new picture box as the new picture box; New webclic strig = "http://graph.facebook.com/" & amp; Sub-heading ("id"). ToString.Replace ("" "," ") & amp;" / pic = width = 126 and height = 114 "strName = subitem (" name "). ToString Client.php file (strID," C: \ wamp \ www \ Img \ "and subitem (" id "). Change (" "", "") and ".jpg") Client.Design () Dim BMP as New Bitmap (Image.FromFile ("C: \ wamp \ www" \ Img \ "& subitem (" id "). ToString.Replace (" "", "" "& amp;" .jpg ")) newPictureBox.BackgroundImage = Image.FromFile (" C: \ WAMP \ www \ img " Toastring. Replace ("" "," "& amp ;." .jpg ") newPictureBox.Tag = Subitem (" id ") ToString.Replace (" "" " "," ") NewPictureBox.Name =" img "& amp; IntX newPictureBox.Width = bmp.Width.ToString () newPictureBox.Height = bmp.Height.ToString () FlowLayoutPanel1.Controls.Add (new picture box) AddHandler newPictureBox.Click, AddressOf new PictureBox_Click intX + = 1 imgDir.Add (str name , Subitem ("Id"). ToString.Replace ("" "," ")) bmp.Dispose () Next  

And it seems that the problem is dim Button . If I add

  newPictureBox.dispose ()  

at the end of that code, then it works with the removal of images from the directory ...

/ P>

Div class = "post-text" itemprop = "text">

This will definitely work for you, sorry for the delay ... Make sure you import System.IO Name locations also import ... When you use the image to create an image, by using the file (strf filename) method, lock the method file. TI is unless you do not release the image. Instead, we can use FileStream to complete this task.

  As an action in the form of an object for each object. Values ​​are new Image as new client in the form of a new client dime client strID = "http://graph.facebook.com/" & amp; Sub-heading ("id"). ToString.Replace ("" "," ") & amp;" / pic = width = 126 and height = 114 "strName = subitem (" name "). ToString Client.php file (strID," C: \ wamp \ www \ Img \ "and subitem (" id "). Change (" "", "") and ".jpg"). Client.Design () Bitmap like dim BMP dim strait string = "C: \ wamp \ www \ img \" & Amp; Sub-heading ("id"). ToString.Replace ("" "," ") &" .jpg "Using New FileStream (strPath, FileMode.Open, FileAccess.Read) b Using FS as the new bitmap (FS) bmp = new bitmap (b.Width, b.Height, b.PixelFormat) using g graphics as = Graphics.FromImage (BMP) g.DrawImage (b, Point.Empty) g.Flush () end of the other end the end using using using newPictureBox.BackgroundImage = bmp newPictureBox.Tag = Subitem ( "ID"). ToString.Replace ( "" "", "") NewPictureBox.Name = "img" & amp; IntX newPictureBox .Width = bmp.Width.ToString () newPictureBox.Height = bmp.Height.ToString () FlowLayoutPanel1.Controls.Add (new image box) Add Handler newPictureBox.Click, AddressOf New PictureBox_Click intX + = 1 imgDir.Add (str name, subitem ("id"). ToString.Replace ("", "")) Next  

Comments

Popular posts from this blog

ios - How do I use CFArrayRef in Swift? -

eclipse plugin - Run java code error: Workspace is closed -

c - Error on building source code in VC 6 -