Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Displaying Data in WebBrowser
#4
Ok. I took another look at it and think I found a solution.

In order for this to work I will need to tell you a little about index's. If you already know about these, you can skip this section. If you add an item to a listbox, It gets an index number. An index number is like an ID number. No two items in the same listbox get the same index number. The first item added to the listbox gets and index of 0. The second item added to the listbox get an index of 1. The index increases each time you add a new item to the listbox. We will use the index numbers to see what item is selected in the listbox.

Now that is out of the way, lets get to work. Delete the sub with the webbrowser text change. No need to have extra code. Also delete the KryptonListBox1_TextChanged sub. It is not needed and is not a real event. (Don't worry about events yet).

Now lets add the code:
Code:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'Add as many items to the listbox you want
        KryptonListBox1.Items.Add("PIE")'First item. Index: 0
        KryptonListBox1.Items.Add("ages")' second item. Index: 1
        KryptonListBox1.Items.Add("VB 2010")'Third Item. Index: 2
    End Sub
This is where the magic happens and the webbrowser's text changes.
Code:
Private Sub KryptonButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles KryptonButton1.Click

        If KryptonListBox1.SelectedIndex = 0 Then 'the first item added to the listbox

            WebBrowser1.DocumentText = "PIE - 'A tasty desert'"

        ElseIf KryptonListBox1.SelectedIndex = 1 Then 'the second item added to the listbox

            WebBrowser1.DocumentText = "A long time - 'It took ages!'"

        ElseIf KryptonListBox1.SelectedIndex = 2 Then 'the third item added to the listbox

            WebBrowser1.DocumentText = "The application your writing this in"
        End If
    End Sub

Hope this one fixes those errors.
--VBCodeGeek--


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)