views:

35

answers:

1

I have a web browser control which has navigated to a given page and is ready. Now I want to bring up the Internet explorer find dialogbox whenever the user clicks a specific button on my page. The user can already bring up the find dialog box by clicking 'ctrl+f', but I want a separate button for this action too.

I have found this: http://support.microsoft.com/kb/329014

But It have the following issues with it:

  1. The page says that this method might not work on later versions of Internet explorer:

    Warning This sample uses an undocumented command-group GUID that is subject to change in the future. Although this sample was tested to work correctly with Internet Explorer 6 and earlier, there is no guarantee that these techniques will continue to work successfully in future versions.

  2. I cant compile the code. I have added the references described in the page but I get errors telling AxSHDocVw namespace could not be found.

+1  A: 

I found a solution myself: If the web browser control name is "web", you can send the "Crtl+f" key to it with the following code:

web.Focus();
SendKeys.Send("^f");

I tested this and it brought up the find dialog box on Internet explorer 8.

Mostafa Mahdieh
This code also uses an undocumented shortcut key that is subject to change in the future (though I doubt Microsoft would change it in the near future), and requires the webbrowser control to have the input focus.It is not that hard to call body.createtextrange, then call findText and select on the text range.
Sheng Jiang 蒋晟