I have an application with a WebBrowser Control. I load a page to it with a button click. Then I want to run a "Convert to Adobe PDF" action from the context menu of the web browser but... when I try to access the context menu by:
foreach (MenuItem vMenuItem in WebBrowser.ContextMenu.MenuItems)
{
if (vMenuItem.Text.Contains("onwert") && vMenuItem.Text.Contains("PDF"))
{
vMenuItem.PerformClick();
}
}
The IDE displays an error "Object reference not set to an instance of an object" on line with
foreach (MenuItem vMenuItem in WebBrowser.ContextMenu.MenuItems)
I didn't create my own context menu, I want the default context menu to show. How can I access the WebBrowser's context menu and perform that action?
i'm having a similar problem to you. I have made a reference to your problem in my post here. If you are still interested in this problem this is working solution that makes use of simulating clicks: