Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Disable popup right click menu or use richtextbox?And how? 1

Status
Not open for further replies.

assimang

Programmer
Mar 11, 2008
96
Hello everybody,

I have 2 textboxes on a form, one for username, and one for password. I want to disable the popup menu appears when I right click on a textbox because I want to avoid paste data, in case these are not allowed characters such as punctuation sticks, symbols etc. Well, how can I achive disabling the popup menu appears when I right click on a textbox?
Is a good idea to use richtextbox instead of textboxes? Does richtextbox provides password chars? And how?
Any help will be much appreciated.

Thank you
in advanced.
 
You don't need a RichTextBox.


To disable the RightClick Menu (and also Control-V for pasting), set:

[tt]ShortcutsEnabled[/tt] property to [tt]False[/tt]


To enable a password to be entered, set:

[tt]PasswordChar[/tt] property to [tt]*[/tt] or your preferred password character.


Hope this helps.

[vampire][bat]
 
I forget to say, the [tt]ShortcutsEnabled[/tt] and [tt]PasswordChar[/tt] properties are available for the TextBox, so you don't need a RichTextBox.

[vampire][bat]
 
Thank you so much earthandfire,
I couldn't imagine that it was so simply to disable both right click and control+v.
 
Only use a RichTextBox if you are going to allow text formatting. There is really no other reason to use one.

-I hate Microsoft!
-Forever and always forward.
 
Thank you too Sorwen, what do you mean to allow text formating? The only text formating I have done in both textboxes is about special characters like punctuation sticks, symbols, greek chacters, upper letters and white space as I mentioned before, and that's why represent username and password. Also, I don't know if RichTextBox provides password char and that's important.
Although I have followed e&f's instructions with no problem. I just ask you because I like to explore more than one solutions and extend my knowledge.
 
Richtext allows you to bold, italicize, color, etc, etc. Basically various text formatting and other things. Generally they are noting happen by default and with disabling pasting you have even less to worry about. Though if you are not going to allow that then there is no reason to use an RTB.

You may actually be using some of that, but from what you said above it didn't sound like it. Like e&f was saying a text box can do all of the other things you mentioned and that means you don't have to worry about trying to stop anything else an RTB may allow.

-I hate Microsoft!
-Forever and always forward.
 
Thank you much Sorwen I don't need a text formating so I'll keep textboxes I think their properly for this situation.[thumbsup2]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top