views:

48

answers:

1

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 
   $Preview.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?!

Thanks,

Ben

A: 

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

Aaaaarghh!

Ben