开发者

Powershell webbrowser refresh makes my content disappear

I am writing a small powershell script using windows forms which generates an HTML signature.

The user can edit size, color etc and the script generates the html as a from their choices, and updates (theoretically) my WebBrowser preview when they press a preview button.

My WebBrowser Control:

$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)  

Update code:

$Preview.DocumentText = $html 
$Pr开发者_StackOverflow中文版eview.Update()
$Preview.Refresh()

This works the first time you run it, i.e. it goes from a blank preview window and updates with the html.

However, every subsequent time the button is pressed it just clears the window?

Anyone know what I'm doing wrong?!


Turns out, all I had to do was remove the $Preview.Update() and $Preview.Refresh() lines.

Aaaaarghh!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜