Popup Menus in Text Boxes

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Using VB.Net, I open a form by using the "MouseDown" event of a textbox control (I test to ensure that the right button has been clicked). However, when I do so, the standard popup menu bar (Undo, Cut, Copy, Paste etc) also sometimes appears. I don't know why it appears sometimes and not others (presumably some sort of timing issue)
In any case, how do I disable this popup menu for a particular text box?
 
Hi,

have a lock at ContextMenu and its menuItems.
Sample can be found on
http://msdn.microsoft.com/library/d...rfsystemwindowsformscontextmenuclasstopic.asp

Add from the toolbar to the form a ContextMenu, name it cm1
Add menuItems as You like them

Select each menuItem to add MenuItem_Click event code

In the TextBox properties look for "ContextMenu" and asign your cm1 you just
added. Done

/anders

Goldsworth_Systems said:
Using VB.Net, I open a form by using the "MouseDown" event of a textbox
control (I test to ensure that the right button has been clicked). However,
when I do so, the standard popup menu bar (Undo, Cut, Copy, Paste etc) also
sometimes appears. I don't know why it appears sometimes and not others
(presumably some sort of timing issue).
 
Thanks for your reply.
I am faimilar with setting my own context menu, however this is not what
want to do in this case.
When the user right clicks on the text box I want it to automatically
load another form, so for this I just use the MouseDown event, rather
than a context menu.
What I need to do is to disable the "in-built" context menu which, as
far as I can see, is automatically attached to a control in the absence
of one of my own.
 
What I need to do is to disable the "in-built" context menu which, as
far as I can see, is automatically attached to a control in the absence
of one of my own.

Just a thought, perhaps the popup is being shown in the MouseUp event.
What happens if you load your form in the MouseUp event instead of
MouseDown? Does that override the popup menu?
 
* Chris Dunaway said:
Just a thought, perhaps the popup is being shown in the MouseUp event.
What happens if you load your form in the MouseUp event instead of
MouseDown? Does that override the popup menu?

Don't forget that the menu should be shown when the user presses the
context menu key on his/her keyboard too. Watching for the
'WM_CONTEXTMENU' and "eating" the message is the way to go.
 
Thanks for your idea - unfortunately I get the same results.
I tried using the double click event, but this doesn't fire for no
reason I can determine. In the end I gave up and am just using a button
 
Back
Top