I am using a listview control and trying to achieve a context menu on the item being selected. But the menu is appearing in the blank area of the form....
here is my code...
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Me.Controls.Add(lv) lv.View = View.Details lv.Dock = DockStyle.Fill il.ColorDepth = ColorDepth.Depth32Bit lv.SmallImageList = il lv.Columns.Add("Button Text", 300, HorizontalAlignment.Left) lv.Columns.Add("PID", 50, HorizontalAlignment.Left) lv.Columns.Add("Process Path", 600, HorizontalAlignment.Left) Dim things As List(Of TrayButton) = TrayHelper.Tray.GetTrayButtons() For Each b As TrayButton In things If b.Icon IsNot Nothing Then il.Images.Add(b.TrayIndex.ToString, b.Icon) Else ' When we can't find an icon, the listview will display this form's one. ' You could try to grab the icon from the process path I suppose. il.Images.Add(b.TrayIndex.ToString, Me.Icon) End If Dim lvi As New ListViewItem(b.Text) lvi.SubItems.Add(b.ProcessIdentifier.ToString) lvi.SubItems.Add(b.ProcessPath) lvi.ImageKey = b.TrayIndex.ToString lv.Items.Add(lvi) Next Dim mnuContextMenu As New ContextMenu() lv.ContextMenu = mnuContextMenu Dim mnuItemHide As New MenuItem() Dim mnuItemExit As New MenuItem() mnuItemHide.Text = "&Hide" mnuItemExit.Text = "&Exit" mnuContextMenu.MenuItems.Add(mnuItemHide) mnuContextMenu.MenuItems.Add(mnuItemExit) End Sub