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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. Handling a paste into a textbox.

Handling a paste into a textbox.

Scheduled Pinned Locked Moved C#
helpquestion
2 Posts 2 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.
  • M Offline
    M Offline
    msx23
    wrote on last edited by
    #1

    Hi all. I am trying to modify some code that clears other textboxes on a form when the user starts entry in a textbox. So I'm handling the KeyDown event of each textbox and clearing the others. But I don't want to clear the other boxes when a CTRL or ALT key is pressed (unless something is pasted into the textbox, which is my problem) so that the user can use shortcuts and such when focused on a textbox. The code I'm using is: if (((Control.ModifierKeys & Keys.Alt) != Keys.Alt) && ((Control.ModifierKeys & Keys.Control) != Keys.Control)) { //Do event handling work here (clear other textboxes etc.) } The problem is that it skips over the stuff it needs to do when a CTRL-V is invoked. How can I handle that while still keeping those CTRL and ALT checks in there. Thanks for any help.

    C 1 Reply Last reply
    0
    • M msx23

      Hi all. I am trying to modify some code that clears other textboxes on a form when the user starts entry in a textbox. So I'm handling the KeyDown event of each textbox and clearing the others. But I don't want to clear the other boxes when a CTRL or ALT key is pressed (unless something is pasted into the textbox, which is my problem) so that the user can use shortcuts and such when focused on a textbox. The code I'm using is: if (((Control.ModifierKeys & Keys.Alt) != Keys.Alt) && ((Control.ModifierKeys & Keys.Control) != Keys.Control)) { //Do event handling work here (clear other textboxes etc.) } The problem is that it skips over the stuff it needs to do when a CTRL-V is invoked. How can I handle that while still keeping those CTRL and ALT checks in there. Thanks for any help.

      C Offline
      C Offline
      Christian Wikander
      wrote on last edited by
      #2

      It's possible to detect if both CTRL and V are pressed at the same time, just extend the if statement. But I think you are better off all together if you use the Change event instead.

      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