Click here to Skip to main content
Rate this: bad
Please Sign up or sign in to vote.
See more: VB HTML VB.NET ListBox
Can anyone offer me some advise? I currently have a listbox i am using, in the listbox there is a list of images from any website. they are grabbed from the website via this method;;;

Private Sub WebBrowser1_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
    Dim PageElements As HtmlElementCollection = WebBrowser1.Document.GetElementsByTagName("img")
    For Each CurElement As HtmlElement In PageElements
        imagestxt.Items.Add(imagestxt.Text & CurElement.GetAttribute("src") & Environment.NewLine)
    Timer1.Enabled = True
End Sub
I then use the picture control method to get the image and display it.
pic1.Image = New System.Drawing.Bitmap(New IO.MemoryStream(New System.Net.WebClient().DownloadData(imagestxtimagestxt.SelectedItem.ToString))).SelectedItem.ToString)))
This method pulls the images and title from the HTML.

Private Function StrHTML12() As Boolean
    Dim htmlDocument As HtmlDocument = WebBrowser1.Document
    For Each element As HtmlElement In htmlDocument.All
        If element.TagName.ToUpper = "IMG" Then
        End If
        If element.TagName.ToUpper = "TITLE" Then
            Timer1.Enabled = False
        End If
End Function
This is a counting method to count how many empty alt="" or emply
Basicly what i am looking to do is;

1) Have a program that can check the image, look at the alt = ' ' or <img a l t = ' ' if on the website the dev hasn't put anything in the alt tag i want the image to show in a picture box and i want the alt tag either next to it or underneith it or something. but i have no idea how.
Posted 25-Feb-13 3:40am
Edited 25-Feb-13 5:55am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

OK .. first create an object that holds the data you want:
Public Class HTMLImages
    Public Image As Image
    Public Description As String
    Public Overrides Function ToString() As String
        Return Description
    End Function
End Class
Then populate your list with the filled objects
Make sure your ListBox.DrawMode is set to DrawMode.OwnerDrawFixed
Handle the ListBox1.DrawItem
Paint what you want if the item is a HTMLImages object
If you need help with GDI+ painting ask me

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Maciej Los 495
1 Sergey Alexandrovich Kryukov 419
2 OriginalGriff 360
3 CHill60 310
4 CPallini 275
0 Sergey Alexandrovich Kryukov 10,017
1 OriginalGriff 9,495
2 Peter Leow 5,241
3 Kornfeld Eliyahu Peter 3,373
4 Maciej Los 3,076

Advertise | Privacy | Mobile
Web03 | 2.8.150327.1 | Last Updated 5 Mar 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100