I'm playing around in VB.NET currently and I'm trying to make it so that the value from my Richtextbox1 goes into my webbrowsers search bar (It's navigating to http://google.com currently..)!
The 'class' of the search bar is "gbqfif".. I was trying things like:
RichTextBox1.Text = WebBrowser1.Document.GetElementById("gbqfif")
Then basically I would invoke a click on the button itself, just trying to get the richtextbox value working first!
If anyone could help, I'd love it! (I searched SOF first before posting)
EDIT: Getting this error alot:
Error 1 'GetElementByClass' is not a member of 'System.Windows.Forms.HtmlDocument'.
You are doing the complete opposite. Your code assigns a text from the webbrowser to the RichTextBox. Change the code to
WebBrowser1.Document.GetElementById("gbqfif").InnerText = RichTextBox1.Text
Related
Okay so I've been searching for a solution for a while but can't seem to find any answers tailored to what I need to do. Also this is my first post here so I'm sorry if I'm being to vague with what I need. Basically I'm creating a program that has a few text boxes on one form and I need to display the data in those text boxes into a list box on another form. There's a button at the bottom of the first form that allows me to switch to form 2 and also display the data in the list box. I can switch to form 2 but nothing shows up in the list box. I also have a few radio buttons and check boxes on form 1 that will affect which constant values will need to show up in form 2's list box as well. One other thing is that I can't just use a form load option for getting data in the list box, it has to happen with the button press because I will be switching between forms and from my understanding the form load option only works once when the form is loaded for the first time. Anyway here is part of my code for form 1 that shows the button click:
Dim strCustomer As String
Private Sub btnPlaceOrder_Click(sender As Object, e As EventArgs) Handles btnPlaceOrder.Click
strCustomer = txtCustomer.Text
frmInvoice.ShowDialog()
frmInvoice.lstCustomerOrder.Items.Add(Me.strCustomer)
End Sub
My first form is frmMain and my second form is frmInvoice. Can anyone please help me with what I need to do differently with this code and what exactly I need to have for my code for form 2 to make this work. Again I am somewhat new to this so I'm sorry if any of this seems vague or if I'm not quite posting this is the right way. Also I'm using VB.
The code you provided should work fine but you are modifying the ListBox after you show the invoice Form. Since you are using showDialog(), the code that follows this statement will only be executed once the dialog form is dealt with (for example if you close it). This means that if you click the button a 2nd time, the ListBox should contain one item. If you switch the two lines so it looks like this, it should do what you expect it to:
frmInvoice.lstCustomerOrder.Items.Add(Me.strCustomer)
frmInvoice.ShowDialog()
I have programmatically added a RichTextBox control to a form, but I seem to be experiencing a lot of issues when trying to format it. Please note that I have manually added the control through the GDI but also encounter the same problems.
Basically what is happening is that my control is drawn but uses the same initial background color as the form (even though I have manually specified a different color). The control also appears empty upon loading of the form, however, I can manually click the mouse the obtain a cursor where text 'should' be appearing.
If I click and drag inside the control, all of my text then appears with all of the formatting I defined. I have no idea what is causing this, but I have tried to Refesh the form, Refresh the Control, Update the control but nothing works. I have also tried using .Text, .SelectedText and .AppendText, as well as .SelectionColor and .SelectionBackColor.
My code is simply this:
Dim rtb As RichTextBox = New RichTextBox
rtb.Location = New Point(94, 229)
rtb.Size = New Size(608, 46)
rtb.BackColor = Color.FromArgb(38, 38, 38)
rtb.ForeColor = Color.LightGray
rtb.AppendText(_ticket.ticket_lastcomment)
Me.Controls.Add(rtb)
Yet it creates a new RichTextBox that is the same color as the form (Color.Control) and empty. No formatting is applied to the control until I highlight the text manually.
I have never come across this before.
UPDATE
After various trial and error and moving code, I have come to find that the piece of code preventing the drawing of the RichTextBox is this:
Me.animator = New FormAnimator(Me, FormAnimator.AnimationMethod.Centre, FormAnimator.AnimationDirection.Right, 200)
I apply a FormAnimator to the form to give it an effect upon opening. Removing this piece of code allows the RichTextBox to draw correctly.....strange.
Try this :)
rtb.rtf =_ticket.ticket_lastcomment
I know its a little late for this answer, but it may help future visitors.
All you have to do, is add first the RichTextBox to the form and then set the text:
Me.Controls.Add(rtb)
rtb.AppendText(_ticket.ticket_lastcomment)
Programming Environment: Visual Studio 2010
Programming Language: VB.NET
I have a tabbed web-browser that I add dynamically, I Dim the the web-browser every-time the user clicks the New Tab button, like this: browser = New WebBrowser() and give it a name based on the tab count, e.g. browser2, if there are 2 tab pages. So my question is - about time - that how would I get the Url of the WebBrowser, I have tried Dim UrlString As String = CType(tabMain.SelectedTab.Controls.Item(browser.Name), WebBrowser).Url.ToString But, correct me if I am wrong, I found that WebBrowser isn't classed as a Control, and the reason why I think this is because:
This gives me an exception: Object reference not set to an instance of an object.
So I tried looping through the controls in the tabMain.SelectedTab and found that the WebBrowser(browser) isn't included in the collection. The code I used to loop was:
For Each ctrl As Control In Me.tabMain.SelectedTab.Controls
MsgBox(ctrl.Name)
Next
Tried looping through all the Parent controls, but no sign of the WebBrowser showing up. Hope this is enough information =P
Thanks in advance.
UPDATE: Figured out the problem, really stupid, and my theory was bullshit too =P. Just ignore =] lol
try this.
Dim UrlString As String = CType(tabMain.Controls.Item(0), WebBrowser).Url.ToString
I assume tabMain is the name of the TabControl. If this is true and each tab has a WebBrowser Control in it then it should work.
This code works fine, the listbox shows the posts. But how do I get the posts on the front side show up as clickable links. Maybe not in the Listbox, perhaps in a panel or similar object?
If objDR.HasRows = True Then
Do While objDR.Read()
ListBox.Items.Add(Convert.ToString(objDR.GetString(1)
Loop
End If
If you want to show it as true links then you can't use the ListBox control. You could use a DataGridView and add a DataGridViewLinkColumn to it.
If you really want to use a ListBox control you could execute the link on the Click event.
I need to go into my implemented web browser and take text from lets say a label on the page. For example on this page it says "Related Questions" I need to copy that text and paste it into my from. Thanks in advance :)
Apparently you're using a WebBrowser element to show a homepage on your form. Use the following short code snippet to get the source code of the website you're viewing (the source code will be written into the TextBox1 in that example). Now you'll just have to filter out whatever you need (in your case it's a certain text which is hopefully between two HTML elements for ease). You might need RegEx for that (in case you're looking for an easy solution).
TextBox1.Text = WebBrowser1.DocumentText