C#中设置webBrowser为可编辑模式
2010年2月6日
没有评论
在网上找了点资料,自己测试了一下,发现C#操作webBrowser也不是很难。这里写几句简单的记录。
首先在from_load事件中添加以下代码:
webBrowser1.DocumentText = string.Empty;
webBrowser1.Document.ExecCommand("EditMode", false, null);
webBrowser1.Document.ExecCommand("LiveResize", false, null);
webBrowser1.DocumentText = @"现在";
然后webBrowser1里面内容就可以编辑了
其中如果需要得到webBrowser1中的内容可以使用:
webBrowser1.Document.Body.InnerText 和 webBrowser1.Document.Body.InnerHtml
从字面意思上可以看出是分别获取webBrowser1的文本形式内容和html形式内容。
Popularity: 14% [?]
最新评论