【问题标题】:Powershell webbrowser refresh makes my content disappearPowershell webbrowser 刷新使我的内容消失
【发布时间】:2014-07-30 18:39:50
【问题描述】:

我正在使用生成 HTML 签名的 Windows 窗体编写一个小型 powershell 脚本。

用户可以编辑大小、颜色等,脚本根据他们的选择生成 html,并在他们按下预览按钮时更新(理论上)我的 WebBrowser 预览。

我的浏览器控件:

$Preview = new-object System.Windows.Forms.WebBrowser
$Preview.Location = new-object System.Drawing.Size(500,30)
$Preview.Size = new-object System.Drawing.Size(260,226)
$Preview.ScrollBarsEnabled = $false
$Form.Controls.Add($Preview)  

更新代码:

$Preview.DocumentText = $html 
$Preview.Update()
$Preview.Refresh()

这在您第一次运行时有效,即它从空白预览窗口进入并使用 html 进行更新。

但是,以后每次按下按钮时它都会清除窗口吗?

有人知道我做错了什么吗?!

【问题讨论】:

    标签: .net winforms powershell


    【解决方案1】:

    事实证明,我所要做的就是删除 $Preview.Update()$Preview.Refresh() 行。

    啊啊啊!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-12-05
      • 1970-01-01
      • 2021-04-21
      • 1970-01-01
      • 1970-01-01
      • 2013-10-22
      • 2014-01-02
      相关资源
      最近更新 更多