custom contextmenustrip for Web Browser control

JuggaloBrotha

VB.NET Forum Moderator
Staff member
Joined
Jun 3, 2004
Messages
4,530
Location
Lansing, MI; USA
Programming Experience
10+
I've been looking for a couple of days now and I can't seem to find anything.

What I'm trying to do is make my own contextmenustrip for the web browser control, this menu has two items so far: "Select All" which will select all the text displayed and "Copy" which simply copies whatever text is highlighted or selected. No images are displayed so no need to worry about that.

Also I've noticed that whenever a file is dragged from windows and dropped onto the web browser control on my form, the browser simply displays the file (these are xml files that I'm dropping on the control, on my form) which is not what I want it to do, instead I want to grab the file path & name and use it elsewhere. The browser control doesn't have the DragEnter, DragDrop, DragLeave events like labels, forms, textboxes, etc... how would I handle this?

I'm noticing that the Browser control isn't nearly as flexible as it could be.
 
Navigating event fires, you can e.Cancel and get e.Url.

Is the contextmenustrip a question? :)
 
I think I'm getting the hang of that Navigate event. I'd forgotten that URL's, even local files, show up in the e.url property

I'd forgotten to actually put the contextmenustrip stuff in the form of a question (that's what I get for doing work on Fridays). The question is, when the menu item is clicked, how do I copy only the selected text in the browser control to the clipboard? I still can't figure this one out, the browser control has a built in menu strip that does it for me, but I can't limit items on that one either.
 
VB.NET:
WebBrowser1.Document.ExecCommand("copy", False, Nothing)
Here is a list of command identifiers, "SelectAll" is also one of them.

You have to turn off the default browser contextmenu to use your own. (IsWebBrowserContextMenuEnabled=False)
 
I saw that yesterday but didn't have time to really get to know what it was about.

Thanks for being on top of this for me.
 
Back
Top