Cassio Posted May 3, 2003 Posted May 3, 2003 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. Quote Stream of Consciousness (My blog)
ailzaj Posted May 3, 2003 Posted May 3, 2003 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 Quote
*Experts* DiverDan Posted May 3, 2003 *Experts* Posted May 3, 2003 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 Quote Member, in good standing, of the elite fraternity of mentally challenged programmers. Dolphins Software
Cassio Posted May 3, 2003 Author Posted May 3, 2003 Will he still be able to ctrl+c? Thanks! Quote Stream of Consciousness (My blog)
*Experts* DiverDan Posted May 4, 2003 *Experts* Posted May 4, 2003 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 Quote Member, in good standing, of the elite fraternity of mentally challenged programmers. Dolphins Software
ailzaj Posted May 4, 2003 Posted May 4, 2003 Have you tried changing the TextBoxes enabled property to false? Then it won't accept any mouse clicks or tab events. ailzaj Quote
Cassio Posted May 4, 2003 Author Posted May 4, 2003 Ok DiverDan, thanks. I was also trying to do something like this: If Not IsNothing(txtpergunta.SelectedText) Then txtpergunta.Select(0,0) End if Quote Stream of Consciousness (My blog)
*Experts* Nerseus Posted May 5, 2003 *Experts* Posted May 5, 2003 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 Quote "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
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.