How to load Images on a Website to a ImageList

Heres your chance to share your own tutorials with the community. Just post them on here. If your lucky they may even be posted on the main site.
1 post Page 1 of 1
Contributors
User avatar
MrAksel
C# Coder
C# Coder
Posts: 1758
Joined: Fri Mar 26, 2010 12:27 pm

Im just going to show you how to create a imagelist that contains all the images that is in a website.
You need a WebBrowser named WebBrowser1, and a ImageList named ImageList1
To load the image into the ImageList use this code:
Code: Select all
        For Each Image As HtmlElement In WebBrowser1.Document.Images

            Dim URL As String = Image.GetAttribute("src") 'Gets the URL of the image

            Try
                Dim NewImage As Image
                Dim ImageStream As Stream
                Dim Request As HttpWebRequest
                Dim Response As HttpWebResponse

                Request = HttpWebRequest.Create(URL) 'Creates a Request for the image
                Response = Request.GetResponse() 'Gets the response
                ImageStream = Response.GetResponseStream() 'Reads the response

                NewImage = System.Drawing.Image.FromStream(ImageStream) 'Creates a image from the response

                ImageList1.Images.Add(NewImage) 'Adds the image to the imagelist
            Catch ex As Exception
                MsgBox("Failed to add the image from the url """ & URL & """.")
            End Try
        Next
Then you can use this imagelist with your listview
LMAOSHMSFOAIDMT
Laughing my a** of so hard my sombrero fell off and I dropped my taco lmao;


Over 30 projects with source code!
Please give reputation to helpful members!

Image
Image
1 post Page 1 of 1
Return to “Tutorials”