现在的位置: 首页 > 综合 > 正文

Webbrowser在鼠标选中的地方插入文本

2012年11月18日 ⁄ 综合 ⁄ 共 730字 ⁄ 字号 评论关闭
using
 System;

using
 System.Collections.Generic;

using
 System.ComponentModel;

using
 System.Data;

using
 System.Drawing;

using
 System.Text;

using
 System.Windows.Forms;

using
 mshtml;


//
添加引用 .Net-Microsoft.mshtml


namespace
 WindowsApplication29


{

    

public
 
partial
 
class
 Form1 : Form

    


{

        

public
 Form1()

        


{

            InitializeComponent();

            

this
.webBrowser1.Navigate(
"
www.google.cn
"
);

        }





        

private
 
void
 button1_Click(
object
 sender, EventArgs e)

        


{

            IHTMLDocument2 doc 

=
 (IHTMLDocument2)
this
.webBrowser1.Document.DomDocument;

            IHTMLTxtRange range 

=
 doc.selection.createRange() 
as
 IHTMLTxtRange;

            range.pasteHTML(range.text

+
"
<div>jinjazz 路过</div>
"
);

        }




    }




}

 

抱歉!评论已关闭.