Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Displaying Data in WebBrowser
#9
brandonio21 Wrote:Hello,
Sorry for not replying until this thread seems to be completely full.

First of all, there is no need to mess around with indexes and such, that may just make your code more confusing. It is much easier just to go straight for the actual text of the listbox item.

So here is some code that should work, it has been tested to work on my system.

Code:
Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        ListBox1.Items.Add("Pie")
        ListBox1.Items.Add("Keyboard")
        ListBox1.Items.Add("Shoes")
    End Sub

    Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
        'First, we clear the exisitng WebBrowser text
        WebBrowser1.DocumentText = ""
        'Then, we set the new text
        writeWebBrowser()
        If WebBrowser1.DocumentText Is Nothing Then
            writeWebBrowser()
        Else
            Trace.TraceError("Error.")
        End If
    End Sub
    Sub writeWebBrowser()
        If ListBox1.SelectedItem.ToString = "Pie" Then WebBrowser1.DocumentText = "Pie - A tasty treat"
        If ListBox1.SelectedItem.ToString = "Keyboard" Then WebBrowser1.DocumentText = "Keyboard - Quite literally, a board of keys"
        If ListBox1.SelectedItem.ToString = "Shoes" Then WebBrowser1.DocumentText = "Shoes - A huge problem facing our communities... Not really."
    End Sub
End Class

Sorry if this is hard to understand, but it is very simple. With this code, the listbox has to be clicked a couple of times....

Please tell me if this works or not. And remember to adjust the element names in the code to your elements!!

You are a legend. Thank you so much. Works perfectly. <!-- sConfusedhock: --><img src="{SMILIES_PATH}/icon_eek.gif" alt="Confusedhock:" title="Shocked" /><!-- sConfusedhock: -->


Messages In This Thread
Displaying Data in WebBrowser - by VicDesigns - 07-26-2011, 03:21 AM
Re: Displaying Data in WebBrowser - by vbcodegeek - 07-26-2011, 11:12 AM
Re: Displaying Data in WebBrowser - by VicDesigns - 07-26-2011, 10:51 PM
Re: Displaying Data in WebBrowser - by vbcodegeek - 07-27-2011, 07:05 AM
Re: Displaying Data in WebBrowser - by VicDesigns - 07-27-2011, 06:18 PM
Re: Displaying Data in WebBrowser - by VicDesigns - 07-28-2011, 06:02 AM
Re: Displaying Data in WebBrowser - by xolara - 07-29-2011, 05:29 AM
Re: Displaying Data in WebBrowser - by VicDesigns - 07-31-2011, 05:32 AM
Re: Displaying Data in WebBrowser - by vbcodegeek - 07-31-2011, 02:01 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How do I fill my form with MySQL data based on Combobox? kismetgerald 8 26,719 10-14-2012, 09:05 PM
Last Post: brandonio21
  Loading DB data into Combobox then populate TextBox Controls kismetgerald 0 5,712 09-02-2012, 08:44 PM
Last Post: kismetgerald
  Extracting Data From A Website Bradley 3 14,719 05-10-2012, 01:03 AM
Last Post: Bradley
  Bookmarking in Webbrowser Gamester699 0 5,917 11-03-2011, 12:28 PM
Last Post: Gamester699
  Update Data Tabel From Edit mfbf 1 8,551 07-30-2011, 12:54 PM
Last Post: brandonio21
  Custom Webbrowser Component vbcodegeek 2 11,524 07-12-2011, 03:56 AM
Last Post: vbcodegeek
  IceGecko WebBrowser Kaine599 3 15,057 02-17-2011, 02:34 PM
Last Post: redpois0n

Forum Jump:


Users browsing this thread: 1 Guest(s)