Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Context MenuStrip & Tabbed WebBrowser...

Status
Not open for further replies.

didijc

Programmer
Jan 2, 2010
4
US
Hey everyone...

I wrote code within visual basic 2008 to create a tab-base web browser...now I want to use my own ContextMenuStrip and not the default one that IE has...but I'm having NO luck what so ever getting my contextmenustrip to show...

I know that if I add the WebBrowser control to my project I can attach my ContextMenuStrip to it within Design mode, but I am creating the browser at runtime and attaching it to the tab panel control...

Does anyone have any suggestion? what am I not seeing?

Code:
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim Browser As New WebBrowser
        TabControl1.TabPages.Add("New Page")
        Browser.Name = "Web Browser"
        Browser.Dock = DockStyle.Fill
        TabControl1.SelectedTab.Controls.Add(Browser)
        AddHandler Browser.ProgressChanged, AddressOf Loading
        AddHandler Browser.DocumentCompleted, AddressOf Done
        int = int + 1
        CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Navigate("about:blank")
        urlBox.AutoCompleteMode = AutoCompleteMode.Suggest
        urlBox.AutoCompleteSource = AutoCompleteSource.HistoryList
        [b]Browser.ContextMenuStrip = ContextMenuStrip1[/b]
    End Sub
 
I can tell you why it isn't working. The problem is that it is a ActiveX control so the ContextMenu it is acutally using is part of the control itself. You can add a context menu at design time because that is part of the base .net control. I'm not sure how to override the ActiveX controls context menu though. I'll post more if I figure anything out.

One other thing it is a bad idea to put a space in the name of a control use at least an underscore.

-I hate Microsoft!
-Forever and always forward.
-My kingdom for a edit button!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top