imagelist from url

Do you need something made? then ask in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
7 posts Page 1 of 1
Contributors
User avatar
dan2130
VIP - Donator
VIP - Donator
Posts: 104
Joined: Sat Sep 26, 2009 3:39 am

imagelist from url
dan2130
hello, i want to know if its possible to add a new picture into an imagelist from a url by example the software get the picture from the web site and add the picture as the image name and after that the picture is usable with listview.
i have tryed to explain the best as possible but if you have some questions you can ask it to me
thanks in advance.
User avatar
MrAksel
C# Coder
C# Coder
Posts: 1758
Joined: Fri Mar 26, 2010 12:27 pm

Re: imagelist from url
MrAksel
I know how to do it, but I'm on m iPod, I'm back in 20 minutes. I understand what you need
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
User avatar
dan2130
VIP - Donator
VIP - Donator
Posts: 104
Joined: Sat Sep 26, 2009 3:39 am

Re: imagelist from url
dan2130
ok thanks
admin@adosrv.net
Owner of ado-srv.net softwares network.
User avatar
MrAksel
C# Coder
C# Coder
Posts: 1758
Joined: Fri Mar 26, 2010 12:27 pm

Re: imagelist from url
MrAksel
If you have a webbrowser control on your form you could take the Images propertynfrom the current HtmlDoument property of the browser. Then you could get the src attribute of each image and load that into the imagelist. I will get some code soon
Here is the code for adding all the images to ImageList1. You can so use that imagelist in your listview
Code: Select all
    For Each Image As HtmlElement In WebBrowser1.Document.Images

            Dim URL As String = Image.GetAttribute("src")

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

                Request = HttpWebRequest.Create(URL)
                Response = Request.GetResponse()
                ImageStream = Response.GetResponseStream

                NewImage = System.Drawing.Image.FromStream(ImageStream)

                ImageList1.Images.Add(NewImage)
            Catch ex As Exception
                MsgBox("Failed to add the image from the url """ & URL & """.")
            End Try
        Next
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
User avatar
dan2130
VIP - Donator
VIP - Donator
Posts: 104
Joined: Sat Sep 26, 2009 3:39 am

Re: imagelist from url
dan2130
sorry but i dont know how i can add the picture in the listview
admin@adosrv.net
Owner of ado-srv.net softwares network.
User avatar
dan2130
VIP - Donator
VIP - Donator
Posts: 104
Joined: Sat Sep 26, 2009 3:39 am

Re: imagelist from url
dan2130
sorry i have found i have edited the line :
ImageList1.Images.Add(NewImage)
to :
ImageList1.Images.Add("Picture name", NewImage)

and after we can add the picture with the items with this code :
Dim str(3) As String
Dim itm As ListViewItem
str(0) = "test111" 'First column
str(1) = "aaaaa" ' second column
str(2) = "sssss" ' third
itm = New ListViewItem(str)
itm.ImageKey = "the picture name"
ListView1.Items.Add(itm)
admin@adosrv.net
Owner of ado-srv.net softwares network.
User avatar
MrAksel
C# Coder
C# Coder
Posts: 1758
Joined: Fri Mar 26, 2010 12:27 pm

Re: imagelist from url
MrAksel
Yea, sorry, but you got it. Please lock your topic now
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
7 posts Page 1 of 1
Return to “Tutorial Requests”