Displaying Data in WebBrowser - Printable Version +- BP Forums (https://bpforums.info) +-- Forum: Archived Forums (https://bpforums.info/forumdisplay.php?fid=55) +--- Forum: Archived Forums (https://bpforums.info/forumdisplay.php?fid=56) +---- Forum: VB.NET (Visual Basic 2010/2008) (https://bpforums.info/forumdisplay.php?fid=8) +----- Forum: Programming Help (https://bpforums.info/forumdisplay.php?fid=9) +----- Thread: Displaying Data in WebBrowser (/showthread.php?tid=368) |
Displaying Data in WebBrowser - VicDesigns - 07-26-2011 Hi folks, I am extremely new to Visual Basic. In fact I have only created one simple program and now want to revamp it. Basically, in a ListBox you select a word and it will display the meaning of that word in a TextBox. Now, what I want to do, is instead of displaying the word meaning in a TextBox, I want to display it in a WebBrowser. I have searched google for the past two days and can not find the code anywhere to do it so I am hoping someone here can provide a working fix? Your help is greatly appreciated. Cheers, Danno Re: Displaying Data in WebBrowser - vbcodegeek - 07-26-2011 Hi VicDesigns. I think I can help you. I am assuming your webbrowsers name = "webbrowser1" and your listboxs name = "listbox1". I'm also guessing your code looks something like this right know? Code: Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged If so, all you need to is change a single line of code. Where the code Textbox1.text = "definition", you just need to replace it with webbrowser1.DocumentText = "Definitioin" Does this Help you out?? Re: Displaying Data in WebBrowser - VicDesigns - 07-26-2011 Hi there, Thank you very much for your help. Unfortunately I am still having issues. I am just getting a blank browser. Here is some of the code to give you an idea. I won't post it all. Here is the first part: Code: Public Class Form1 Part of The ListBox part: Code: Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load And Part of the WebBrowser part: Code: Private Sub KryptonButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles KryptonButton1.Click Now that code, along with the rest of it, if I change the WebBrowser back to TextBox or, in this case, KryptonTextBox1, it will work flawlessly. But I would really like to get it to diaply in the webbrowser because it looks more awesome. I hope yourself or someone can help. Thank you so much in advance. Re: Displaying Data in WebBrowser - vbcodegeek - 07-27-2011 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 Code: Private Sub KryptonButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles KryptonButton1.Click Hope this one fixes those errors. Re: Displaying Data in WebBrowser - VicDesigns - 07-27-2011 Hi mate, Yeah I made the changes etc. However I am still getting a blank browser. <!-- shock: --><img src="{SMILIES_PATH}/icon_eek.gif" alt="hock:" title="Shocked" /><!-- shock: --> <-- Love that smilie. <!-- s --><img src="{SMILIES_PATH}/icon_e_smile.gif" alt="" title="Smile" /><!-- s --> It seems the ListBox is not communicating with the Search TextBox nor the button. So I am guessing this is why I am not getting anything displayed on the browser. I will play around with it some more and see if I can figure out WTF is going on and will let you know. <!-- s --><img src="{SMILIES_PATH}/icon_e_smile.gif" alt="" title="Smile" /><!-- s --> Thanks again for your help. Much appreciated. Re: Displaying Data in WebBrowser - VicDesigns - 07-28-2011 Nah. Ripped it apart and redid it using the two pieces of code you provided and still getting a blank browser. Oh well. Guess it aint meant to be. <!-- s --><img src="{SMILIES_PATH}/icon_e_smile.gif" alt="" title="Smile" /><!-- s --> Re: Displaying Data in WebBrowser - xolara - 07-29-2011 Hello Uh since i was too lazy today to read all what you wrote i went ahead and made a project file for you to download so please let me know if this was not what you were looking for But here is the link: <!-- m --><a class="postlink" href="http://dl.dropbox.com/u/12582973/listboxwithwebbrowser.zip">http://dl.dropbox.com/u/12582973/listbo ... rowser.zip</a><!-- m --> EDIT: If this did not help you are welcome to add me on msn and i can talk you through it: <!-- e --><a href="mailto:Jeg-Kan-Li-Kage@Hotmail.Com">Jeg-Kan-Li-Kage@Hotmail.Com</a><!-- e --> Re: Displaying Data in WebBrowser - brandonio21 - 07-30-2011 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 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!! Re: Displaying Data in WebBrowser - VicDesigns - 07-31-2011 brandonio21 Wrote:Hello, You are a legend. Thank you so much. Works perfectly. <!-- shock: --><img src="{SMILIES_PATH}/icon_eek.gif" alt="hock:" title="Shocked" /><!-- shock: --> Re: Displaying Data in WebBrowser - vbcodegeek - 07-31-2011 I Wish I would of know that. Would of made my projects a lot more easier <!-- s --><img src="{SMILIES_PATH}/icon_e_sad.gif" alt="" title="Sad" /><!-- s --> Re: Displaying Data in WebBrowser - brandonio21 - 08-01-2011 VicDesigns Wrote:You are a legend. Thank you so much. Works perfectly. <!-- shock: --><img src="{SMILIES_PATH}/icon_eek.gif" alt="hock:" title="Shocked" /><!-- shock: --> No problem man! Glad I could help! And remember, if you have anymore problems, feel free to ask them on BP Forums!! |