Popup menu in VB.Net, equivalent to VB6?

Viewed 1077

In VB6 I am using Menu Editor to store a list of students. e.g. Students ....Bob ....Joe ....Bill ....James

PopupMenu Students

I then used the Visual studio 2008 wizard to convert the Vb6 project to .NET.

How can I get this menu to work in .Net without too much change(event if the solution involves importing a VB6 DLL to .Net)?

In .Net Student is now :

Public WithEvents Students As System.Windows.Forms.ToolStripMenuItem

So I did:

Students.ShowDropDown()

instead of:

PopupMenu Students

And it all works except the location. .net seems to be forcing the location to be 0,0. And I would like the menu to popup at the mouse click as it would in VB6.

VB.NET Code:

<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> Partial Class StudentForm

    Public WithEvents Students As System.Windows.Forms.ToolStripMenuItem
    Public WithEvents John As System.Windows.Forms.ToolStripMenuItem
    Public WithEvents MainMenu1 As System.Windows.Forms.MenuStrip
    Friend WithEvents ContextMenuStrip1 As ContextMenuStrip

    //Initialise Component
    Private Sub InitializeComponent()
        Me.ContextMenuStrip1 = New System.Windows.Forms.ContextMenuStrip(Me.components)
        Me.ContextMenuStrip1.Name = "ContextMenuStrip1"
        Me.ContextMenuStrip1.Size = New System.Drawing.Size(181, 26)
        Me.Students = New System.Windows.Forms.ToolStripMenuItem
        Me.John = New System.Windows.Forms.ToolStripMenuItem
        Me.MainMenu1 = New System.Windows.Forms.MenuStrip
        Me.MainMenu1.SuspendLayout()

        Me.Students.Name = "Students"

        Me.Students.Text = "Students"

        Me.Students.Visible = False

        Me.Students.Checked = False

        Me.Students.Enabled = True


        Me.John.Name = "John"

        Me.John.Text = "Johnny"

        Me.John.Checked = False

        Me.John.Enabled = True

        Me.John.Visible = True

        MainMenu1.Items.AddRange(New System.Windows.Forms.ToolStripItem(){ Me.Students})
        Students.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem(){ Me.John})
        Me.MainMenu1.ResumeLayout(False)
    End Sub
End Class

'MouseUp Event - 
Students.ShowDropDown()' This work well bot the location is 0,0- not sure how to change

' I Also Tried Adding the context menu
ContextMenu1.Items.Add(Students)- ' This does not show with sudents. But it shows if I do `ContextMenu1.Items.Add("Test")`
ContextMenu1.Show()
0 Answers
Related