none
How To Enable A Context Menu For A TextBox RRS feed

  • Question

  • Hi:

    In VB2019 I am having trouble implementing a context menu that I have created for

    textboxes. I have set the TB shortcuts to "enabled" and I have specified the name

    of the context menu but nothing happens on a right-click.

    Thanks

    Tuesday, July 2, 2019 8:14 PM

Answers

  • Hello,

    If you had an earlier version of Visual Studio did you try it in a project in that version? 

    I assume by shortcuts to enable you mean ShortcutsEnable = True (which is the default) and that you assigned the TextBox a context menu.


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Tuesday, July 2, 2019 8:36 PM
    Moderator

All replies

  • Hello,

    If you had an earlier version of Visual Studio did you try it in a project in that version? 

    I assume by shortcuts to enable you mean ShortcutsEnable = True (which is the default) and that you assigned the TextBox a context menu.


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Tuesday, July 2, 2019 8:36 PM
    Moderator
  • Hi:

    It worked in earlier versions with other apps. I have used the settings as

    you show but it won't work for me in vb2019.


    Tuesday, July 2, 2019 8:42 PM
  • Hi:

    It worked in earlier versions with other apps. I have used the settings as

    you show but it won't work for me in vb2019.


    Hello,

    This mean you need to report this as an issue via the top of the IDE right side icon that should have a black silhouette of a person. It may be in a different location as I have not upgraded to VS2019 as I tend to wait six or so months till the kinks are ironed out. Seems you have found one.


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Tuesday, July 2, 2019 10:45 PM
    Moderator
  • Hi:

    In VB2019 I am having trouble implementing a context menu that I have created for

    textboxes. I have set the TB shortcuts to "enabled" and I have specified the name

    of the context menu but nothing happens on a right-click.

    Thanks

    Hi

    Windows 10 using VS 2019 Community here.

    I can't find any issues with ContextMenuStrips in TextxBoxes.

    To illustrate, I set up some random TextBoxes at Form level and in a couple of containers (Panel and FlowLayoutPanel)

    In code, I assigned the ContextMenuStrip to all TextBoxes and tested. All seems to work fine for me.

    Here is what I tested with, try it out to verify that the issue is occurring on your system.

    ' Test project - Designer has
    ' any number of TextBoxes which
    ' can be at Form level or within
    ' other containers.
    ' Here, I have used Form level,
    ' Panel container and FlowLayoutPanel
    ' to test.
    Option Strict On
    Option Explicit On
    Public Class Form1
    	Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    		For Each c As Control In Controls
    			If c.GetType = GetType(TextBox) Then
    				c.ContextMenuStrip = ContextMenuStrip1
    			Else
    				For Each cc As Control In c.Controls
    					If cc.GetType = GetType(TextBox) Then
    						cc.ContextMenuStrip = ContextMenuStrip1
    					End If
    				Next
    			End If
    		Next
    	End Sub
    	Private Sub OneToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles OneToolStripMenuItem.Click, TwoToolStripMenuItem.Click, ThreeToolStripMenuItem.Click
    		Dim tb As ToolStripMenuItem = DirectCast(sender, ToolStripMenuItem)
    		Dim contextMS As ContextMenuStrip = CType(tb.Owner, ContextMenuStrip)
    		MessageBox.Show("You selected " & tb.Text & vbCrLf & " from the " & contextMS.SourceControl.Name & " ContextMenuStrip")
    	End Sub
    End Class


    Regards Les, Livingston, Scotland


    • Edited by leshay Wednesday, July 3, 2019 12:44 AM
    Wednesday, July 3, 2019 12:43 AM