Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/337.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何在System.Windows.Forms.WebBrowser中设置文本宽度?_C#_Winforms_Webbrowser Control - Fatal编程技术网

C# 如何在System.Windows.Forms.WebBrowser中设置文本宽度?

C# 如何在System.Windows.Forms.WebBrowser中设置文本宽度?,c#,winforms,webbrowser-control,C#,Winforms,Webbrowser Control,我目前正在使用control System.Windows.Forms.WebBrowser在Windows应用程序中创建所见即所得编辑器。 基本上我需要的是文本不超过控件的宽度,即我不想使用水平滚动条 可能吗 [更新] 以下是我正在运行的代码: Reconocimiento.Navigate("about:blank"); //this is my object System.Windows.Forms.WebBrowser Reconocimiento.Document.OpenNew(

我目前正在使用control System.Windows.Forms.WebBrowser在Windows应用程序中创建所见即所得编辑器。 基本上我需要的是文本不超过控件的宽度,即我不想使用水平滚动条

可能吗

[更新]

以下是我正在运行的代码:

 Reconocimiento.Navigate("about:blank"); //this is my object System.Windows.Forms.WebBrowser
 Reconocimiento.Document.OpenNew(false);
 string html = "<html><head><style type=\"text/css\">body {width: 400px;}</style></head><body></body></html>";
 Reconocimiento.Document.Write(html);
 recon = (Reconocimiento.Document.DomDocument) as IHTMLDocument2;
 recon.designMode = "On"; //What we just did was make our web browser editable!

您可以使用css分词属性

创建一个包含以下内容的文件,并将其保存为C:\default.html或某个应用程序路径

<html>    
  <body style='word-break: break-all'>
  <body>
</html>

你用它来打这个问题。你有没有看到一个水平滚动条?你有没有看表单设计器,看看有多大,然后修改它。汉斯:触摸,他们在Stackoverflow中是怎么做的。现在Cold:我想我应该激活垂直而不是水平,并更改控件的宽度,但这不会发生。也许我可以使用这个,但无法使用createStyleSheetSheng方法。Sheng:正如你所看到的,上面是我使用的代码,我没有使用iframe
Reconocimiento.Navigate(new Uri("file:///C:/default.html"));