Private Sub webBrowser1_Navigated(ByVal sender As Object, _īyVal e As WebBrowserNavigatedEventArgs) _ ' Updates the URL in TextBoxAddress upon navigation. If address.Equals("about:blank") Then Return If String.IsNullOrEmpty(address) Then Return Private Sub Navigate(ByVal address As String) ' Navigates to the given URL if it is valid. ' the ENTER key is pressed while the ToolStripTextBox has focus.īyVal sender As Object, ByVal e As KeyEventArgs) _īyVal sender As Object, ByVal e As EventArgs) _ ' Navigates to the URL in the address box when Private void webBrowser1_Navigated(object sender, If (address.Equals("about:blank")) return If (String.IsNullOrEmpty(address)) return Navigates to the given URL if it is valid. Private void goButton_Click(object sender, EventArgs e) Private void toolStripTextBox1_KeyDown(object sender, KeyEventArgs e) the ENTER key is pressed while the ToolStripTextBox has focus. Navigates to the URL in the address box when This->TextBoxAddress->Text = this->WebBrowser1->Url->ToString() Void WebBrowser1_Navigated( Object^ /*sender*/, System::Windows::Forms::WebBrowserNavigatedEventArgs^ /*e*/ ) Updates the URL in TextBoxAddress upon navigation. If ( !this->TextBoxAddress->Text->Equals( "" ) ) Void ButtonGo_Click( System::Object^ /*sender*/, System::EventArgs^ /*e*/ ) Navigates to the URL in the address text box when This->WebBrowser1->Navigate( this->TextBoxAddress->Text ) If ( e->Ke圜ode = System::Windows::Forms::Keys::Enter & !this->TextBoxAddress->Text->Equals( "" ) ) Void TextBoxAddress_KeyDown( Object^ /*sender*/, System::Windows::Forms::KeyEventArgs^ e ) the ENTER key is pressed while the text box has focus. When you navigate by clicking a hyperlink, the text box automatically updates to display the current URL.įor the complete code example, see How to: Add Web Browser Capabilities to a Windows Forms Application. When you type a URL into the text box and press ENTER or click the Go button, the WebBrowser control navigates to the URL specified. This example requires that you have a form that contains a WebBrowser control called webBrowser1, a TextBox control called TextBoxAddress, and a Button control called ButtonGo. The following code example demonstrates how to implement an address bar for use with the WebBrowser control. Inherit WebBrowserBase Public Class WebBrowserĬlassInterfaceAttribute ComVisibleAttribute DockingAttribute Examples In this article public ref class WebBrowser : System::Windows::Forms::WebBrowserBase Handling this event is useful, for example, to change the enabled state of a Forward button when the WebBrowser control navigates to or leaves the end of the navigation history.Enables the user to navigate Web pages inside your form. Handle the CanGoForwardChanged event to receive a notification when the CanGoForward property value changes. Use the CanGoForward property to determine whether the navigation history is available and contains a page located after the current one. You can use the GoForward method to implement a Forward button similar to the one in Internet Explorer, allowing your users to return to the next page in the navigation history after navigating backward. The WebBrowser control maintains a history list of all the Web pages visited during a browsing session. Private Sub webBrowser1_CanGoForwardChanged( _įorwardButton.Enabled = webBrowser1.CanGoForward ' Disables the Forward button at the end of navigation history. ' Navigates webBrowser1 to the next page in history.īyVal sender As Object, ByVal e As EventArgs) _ Private void webBrowser1_CanGoForwardChanged(object sender, EventArgs e)įorwardButton.Enabled = webBrowser1.CanGoForward Private void forwardButton_Click(object sender, EventArgs e) Navigates webBrowser1 to the next page in history. This->ButtonForward->Enabled = this->WebBrowser1->CanGoForward Void WebBrowser1_CanGoForwardChanged( System::Object^ /*sender*/, System::EventArgs^ /*e*/ ) Disables the Forward button at the end of navigation history. Void ButtonForward_Click( System::Object^ /*sender*/, System::EventArgs^ /*e*/ ) Navigates WebBrowser1 to the next page in history. This example requires that your form contains a WebBrowser control called webBrowser1 and a Button control called ButtonForward.įor the complete code example, see How to: Add Web Browser Capabilities to a Windows Forms Application. The following code example demonstrates how to use the GoForward method to implement a Forward button for the WebBrowser control similar to the one in Internet Explorer. True if the navigation succeeds false if a subsequent page in the navigation history is not available. public:īool GoForward() public bool GoForward () member this.GoForward : unit -> bool Public Function GoForward () As Boolean Returns Boolean Navigates the WebBrowser control to the next page in the navigation history, if one is available.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |