Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I want to disable the buttons of the mouse when its clicked on a textbox, so the user wont select and copy its contents. Whats the best way to do this? What i´m doing is putting the foccus on another control, like this:

 

Private Sub txtpergunta_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles txtpergunta.MouseDown
       If e.Button = MouseButtons.Left Or e.Button = MouseButtons.Right Then
           cmdAvançar.focus()
       End If
   End Sub

 

But this is ugly.

Posted

This does what you wanted, but I don't know if it looks any prettier...

 

If btnMouse.MouseButtons.Left Or btnMouse.MouseButtons.Right Then

cmdExit.Focus()

End If

 

ailzaj

  • *Experts*
Posted

Or you can completely disable the context menu from showing in the textbox, eliminating the need to tranfer focus.

 

txtpergunta.ContextMenu = New ContextMenu()

 

Hope this works for you.

Dan

Member, in good standing, of the elite fraternity of mentally challenged programmers.

 

Dolphins Software

  • *Experts*
Posted

Only if you program txtpergunta to accept ctrl+c, or in you're case, program it not to accept ctrl+c via your forms keydown or keyup event handler.

 

esta bien?

Dan

Member, in good standing, of the elite fraternity of mentally challenged programmers.

 

Dolphins Software

  • *Experts*
Posted

Check out this FAQ. The link points to the Textbox portion.

 

DiverDan has it half right - you want to disable the context menu. You'll also need to trap for keyboard to prevent Ctrl-C. It's in the FAQ (I think it's Ctrl-V for paste, but you can get it).

 

-Nerseus

"I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...