Link to home
Start Free TrialLog in
Avatar of tonelm54
tonelm54

asked on

Tab Page ContextMenuStrip AddHandler

Good evening,
Im trying to add a ContextMenu strip to a tab page which adds different items, depending on the tab created.

I have 2 problems, the first is when I run the line 'tp.ContextMenuStrip.Items.Add("Close this")' I get 'Object reference not set to an instance of an object.'

And if I set it as a context menu and add a static menu (not what I wanna do), my handeler doesnt work.

Any ideas?
Dim tp As New TabPage

            tp.Text = "Transactions for '" & e.ClickedItem.Text & "'"
            tp.ContextMenuStrip.Items.Add("Close this")
            tp.ContextMenuStrip.Items.Add("Close all but this")
            tp.ContextMenuStrip.Items.Add("Close all")

            AddHandler tp.ContextMenuStrip.Click, AddressOf tabContextMenuStripClick

            tcWindows.TabPages.Add(tp)






    Private Sub tabContextMenuStripClick(ByVal sender As System.Object, ByVal e As System.EventArgs)

    End Sub

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial