views:

125

answers:

2

I’m using the WebBrowser control as a html editor in a WinForm application I am building. I have a button which pastes some text into the WebBrowser control which works fine on every machine except 1! Here is the code behind the button click event:

Clipboard.SetText("Some text ...")
WebBrowser.Document.ExecCommand("paste", False, Nothing)

I’ve tracked the problem down to the 2nd line of code. What confuses me even more is that if the user uses the “paste” option on the standard right click menu of the WebBrowser control then it pastes the text in fine.

Has anyone any ideas on what could be wrong here?

A: 

Hi,

I've faced similar problem and it was resolved by adding a Thread.sleep(500) before pasting the text from the clipboard (you can change the 500 in my case it was sufficient).
I know that it doesn't look a right way to solve it, but i think this is the only way to do it, and as i had noticed that this problem appears only when i tried to install it on slow machines.

Gaby
Unfortunately this didn't work for me.
rip
+1  A: 

I've fixed this problem - it seems to be a security restriction with IE - The security level in IE needs to be medium (Tools > Internet Options > security > Internet > Medium level)

rip