How can I make the WebBrowser control navigate to a specific webpage?
Posted
by
tee
on Stack Overflow
See other posts from Stack Overflow
or by tee
Published on 2010-12-25T07:24:09Z
Indexed on
2010/12/25
7:54 UTC
Read the original article
Hit count: 261
How can I make the code when run the code it go to samsung.com
private void webBrowser1_Navigated(object sender, WebBrowserNavigatedEventArgs e)
{
webBrowser1.Navigate("www.samsung.com");
}
Please correct it when run program it go to samsung.com
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using mshtml;
namespace webhiglight
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void webBrowser1_Navigated(object sender, WebBrowserNavigatedEventArgs e)
{
webBrowser1.Navigate("www.samsung.com");
}
private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
if (webBrowser1.Document != null)
{
IHTMLDocument2 document = webBrowser1.Document.DomDocument as IHTMLDocument2;
if (document != null)
{
IHTMLSelectionObject currentSelection = document.selection;
IHTMLTxtRange range = currentSelection.createRange() as IHTMLTxtRange;
if (range != null)
{
const String search = "ant";
if (range.findText(search, search.Length, 2))
{
range.select();
}
}
}
}
}
}
}
© Stack Overflow or respective owner