Web浏览器控制VB [英] Webbrowser control VB
问题描述
我将一个html内容从richtextbox传递到webbrowsercontrol
WebBrowser1.DocumentText = richtextbox1.Text
和web控件是显示已转换的HTML。好!!
但它不允许我在webbrowser控件中编辑转换后的html(比如更改消息)。
when我用
WebBrowser1.Document.ExecCommand(EditMode,False,DBNull.Value)
这清除了webbrowser控件中允许我写的所有内容。
我知道如何在webbrowercontrol中编辑我的消息?
我没有试过这个,但你可以试试DesignMode属性:
私有 Sub WebBrowser1_DocumentCompleted( ByVal sender 作为系统。对象, ByVal e 作为 System.Windows.Forms.WebBrowserDocumentCompletedEventArgs)句柄 WebBrowser1.DocumentCompleted
obj = WebBrowser1.ActiveXInstance
obj.document.designmode = On
Application.DoEvents()
结束 Sub
'要加粗文字
WebBrowser1.Document.ExecCommand(Bold,False ,没什么)
'为文字加下划线
WebBrowser1.Document.ExecCommand( 下划线,虚假,没有)
'要Italisize Text
WebBrowser1 .Document.ExecCommand(Italic,False,Nothing)
'设置文本字体
WebBrowser1.Document.ExecCommand(FontName,False,Calibri)
'设置文本字体颜色
WebBrowser1.Document.ExecCommand(ForeColor,False,Color.Red)
'设置文字返回颜色
WebBrowser1.Document.ExecCommand(BackColor,False,ColorDialog1.Color)
'左对齐
WebBrowser1.Document.ExecCommand(JustifyLeft,False,Nothing)
'中心对齐
WebBrowser1.Document.ExecCommand(JustifyCenter,False,Nothing)
'右对齐
WebBrowser1.Document.ExecCommand(JustifyRight,False,Nothing)
在事件WebBrowser1_DocumentCompleted
之后设置DocumentText属性,并使用hot命令
添加图片
I am passing a html content from a richtextbox to webbrowsercontrol
WebBrowser1.DocumentText = richtextbox1.Text
and the web control is showing converted HTML. Good !!
but it is not allowing me to edit the converted html (like to change the message) in webbrowser control.
when i use
WebBrowser1.Document.ExecCommand("EditMode", False, DBNull.Value)
this clears off everything in the webbrowser control allowing me to write.
Any idea how i can edit my message in webbrowercontrol ?
I haven't tried this, but you can try the DesignMode Property:
Private Sub WebBrowser1_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted obj = WebBrowser1.ActiveXInstance obj.document.designmode = "On" Application.DoEvents() End Sub
'To Bold Text
WebBrowser1.Document.ExecCommand("Bold", False, Nothing)
'To Underline Text
WebBrowser1.Document.ExecCommand("Underline", False, Nothing)
'To Italisize Text
WebBrowser1.Document.ExecCommand("Italic", False, Nothing)
'To Set Text Font
WebBrowser1.Document.ExecCommand("FontName", False, "Calibri")
'To Set Text Font color
WebBrowser1.Document.ExecCommand("ForeColor", False, Color.Red)
'To Set Text Back Color
WebBrowser1.Document.ExecCommand("BackColor", False, ColorDialog1.Color)
'To Align Left
WebBrowser1.Document.ExecCommand("JustifyLeft", False, Nothing)
'To Centre Align
WebBrowser1.Document.ExecCommand("JustifyCenter", False, Nothing)
'To Right Align
WebBrowser1.Document.ExecCommand("JustifyRight", False, Nothing)
Set the DocumentText property after event WebBrowser1_DocumentCompleted
and hot to add a picture usin that command
这篇关于Web浏览器控制VB的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!