Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. disable paste in a textbox

disable paste in a textbox

Scheduled Pinned Locked Moved C#
question
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    Tyrus182
    wrote on last edited by
    #1

    hi id like to prevent people from pasting in my text box what is the best way to trap the keyboard commands and stop the paste menu from poping up on right click?

    M 1 Reply Last reply
    0
    • T Tyrus182

      hi id like to prevent people from pasting in my text box what is the best way to trap the keyboard commands and stop the paste menu from poping up on right click?

      M Offline
      M Offline
      Martin 0
      wrote on last edited by
      #2

      Hello Tyrus, In this case you should use the KeyDown Event. this.textbox.KeyDown += new KeyEventHandler(CheckKeys); private void CheckKeys(object sender, KeyEventArgs e) { if (e.Control && e.KeyCode == Keys.V) e.Handled = true; } All the best, Martin

      T 1 Reply Last reply
      0
      • M Martin 0

        Hello Tyrus, In this case you should use the KeyDown Event. this.textbox.KeyDown += new KeyEventHandler(CheckKeys); private void CheckKeys(object sender, KeyEventArgs e) { if (e.Control && e.KeyCode == Keys.V) e.Handled = true; } All the best, Martin

        T Offline
        T Offline
        Tyrus182
        wrote on last edited by
        #3

        any idea how i can disable the context menu that pops up with i right click?

        M V 2 Replies Last reply
        0
        • T Tyrus182

          any idea how i can disable the context menu that pops up with i right click?

          M Offline
          M Offline
          Martin 0
          wrote on last edited by
          #4

          Hello Tyrus, Maybe for your project it would be helpfull if you use a MYTextBox class which inherits from windowsd Textbox. There you can override the MouseUp Event. protected override void OnMouseUp(MouseEventArgs e) { if(e.Button != MouseButtons.Right) { base.OnMouseUp (e); } } Hope it works for you! All the best, Martin

          1 Reply Last reply
          0
          • T Tyrus182

            any idea how i can disable the context menu that pops up with i right click?

            V Offline
            V Offline
            Vipin Venugopal
            wrote on last edited by
            #5

            On the body tag just write the following code. It will disable the right Click in a page. Vipin

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups