views:

71

answers:

2

Using winform w/vb.net. When I have form w/a textbox and one right-clicks on the textbox a context menu pops up w/copy/paste options. How do I disable this from poping up (I want to use the right-click for my one function)?

A: 

Quick dirty hack = create a blank context menu and assign it to the textbox.

 ContextMenu _blankContextMenu = new ContextMenu();
 textBox1.ContextMenu = _blankContextMenu; 

Code is in C# but it should be the same in VB.

Adrian Faciu
But I would need to do this to each textbox, and I do want to intercept the right-click.
bochur1
So write a function to loop through all your textboxes and set the blank contextmenu suggested to each of them
Matt
A: 

I just want to throw in my two cents here. One of the most important aspects of software design is UI consistency. Since you are developing a WinForm application, your users will likely expect to be able to perform operations inside your application that they can perform in other Windows applications. So, instead of trying to swallow the right click context menu provided for the sake of consistency, why not use a different calling method to fire your function?

Again, just one person's opinion.

ShaunLMason