简体   繁体   English

WebBrowser对象的内容在最小化表单然后恢复时会更改位置

[英]WebBrowser object content changes position when form is minimized and then restored

I've written a C# app that uses a webbrowser for its main content window. 我编写了一个使用Web浏览器作为其主要内容窗口的C#应用​​程序。 The program loads a rather large amount of text into that browser, which works fine. 该程序将相当大量的文本加载到该浏览器中,效果很好。 I've noticed when reading that content, however, that if I minimize the application and then restore it that the position jumps way up in the text instead of remaining where it was. 但是,在阅读该内容时,我注意到,如果我最小化应用程序然后还原它,则该位置在文本中会跳得更高,而不是保持原样。 Doing this several times puts the text at the top of the content. 多次执行此操作会将文本放在内容的顶部。

Any ideas what could cause this and what I could do to stop this behavior? 有什么想法可能导致这种情况,以及我该怎么做才能阻止这种行为? It's only when I minimize/restore, if I alt-tab into another application and go back the position is properly retained. 只有当我最小化/还原时,如果我按Alt键进入另一个应用程序并返回,该位置才被正确保留。

Here are screenshots of the content: Before minimizing: http://imageshack.us/a/img641/9632/beforeminimize.jpg After restore: http://imageshack.us/a/img827/439/afterrestore.jpg 以下是内容的屏幕快照:最小化之前: http : //imageshack.us/a/img641/9632/beforeminimize.jpg还原后: http : //imageshack.us/a/img827/439/afterrestore.jpg

Here is a link to the code on GitHub, though I haven't changed any properties of the WebBrowswer aside from its anchors: https://github.com/benroth/FanBook 这是GitHub上代码的链接,尽管除锚点外,我没有更改WebBrowswer的任何属性: https : //github.com/benroth/FanBook

I think you can try the below steps: 我认为您可以尝试以下步骤:

  1. Open Windows form in design mode. 在设计模式下打开Windows窗体。
  2. Select Web Browser Control > Goto > Properties. 选择“ Web浏览器控件”>“转到”>“属性”。
  3. Specify [Dock] property to None. 将[Dock]属性指定为None。
  4. In code behind, specify the height and width for the Web Browser Control. 在后面的代码中,指定Web浏览器控件的高度和宽度。

I do have the similar problem and got fixed following the above steps. 我确实有类似的问题,并按照上述步骤进行了修复。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 当游戏最小化时,RenderTarget内容会更改 - RenderTarget content changes when game is minimized 最小化“窗体”窗口状态时,Webbrowser控件引发异常 - Webbrowser control throws exception when Form windowstate is minimized 从最小化状态还原后,如何重新绘制表单? - How do I repaint a form after it was restored from a minimized state? 最小化然后恢复时,渐变面板显示红叉 - Gradient Panel shows red cross when minimized and then restored 窗口最小化后不恢复 - Window is not restored after minimized WPF 最小化拥有的窗口应该保持最小化,如果 Parent 被最小化然后恢复 - WPF minimized owned windows should stay minimized, if Parent is minimized and then restored 最小化主窗体时将窗体设置为CenterParent - Setting Form to CenterParent when main form is minimized 更改选项卡选择时,除非最小化,最大化或恢复widnow屏幕,否则不会重绘子面板 - When changing tab selections, child panels are not redrawn unless widnow screen is minimized, maximized or restored asp.net 浏览器页面最小化/向下恢复时的页面调整 state - asp.net page adjustment when browser page is minimized/restored down state 将表格最小化到托盘时单击鼠标右键 - Right click when form is minimized to tray
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM