private void CreateHyperlinkFromSelection()
{
if (webBrowser1.Document != null)
{
mshtml.IHTMLDocument2 iDoc = (mshtml.IHTMLDocument2)webBrowser1.Document.DomDocument;
if (iDoc != null)
{
mshtml.IHTMLSelectionObject iSelect = iDoc.selection;
if (iSelect == null)
{
MessageBox.Show("Please select some text before using this command.");
return;
}
mshtml.IHTMLTxtRange txtRange = (mshtml.IHTMLTxtRange)iSelect.createRange();
// Create the link.
if (txtRange.queryCommandEnabled("CreateLink"))
{
Object o = null;
txtRange.execCommand("CreateLink", true, o);
}
}
}
}