Results 1 to 6 of 6

Thread: Paste into multiple textboxes at once

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Nov 2009
    Posts
    16

    Paste into multiple textboxes at once

    Hi

    Is there a way to copy multiple delmited items and paste them into multiple textboxes on a windows form at once?

    I have a form with 5 text boxes, if you click in the first textbox and press the tab key it jumps to the next textbox.

    so lets say I copy data from notepad :
    ThisShouldGoIntoTextBox1
    ThisShouldGoIntoTextBox2
    ThisShouldGoIntoTextBox3
    ThisShouldGoIntoTextBox4
    ThisShouldGoIntoTextBox5

    and click on the first textbox on the form and press paste, it will only paste the first line.

    Is there a way to add that "tab" character to the end of each line, so when I paste the data, it will automatically fill all the texboxes?

    I know this is possible in browsers with plugins, but i want to do this onto an existing windows form which code I am not allowed to change.

    Regards
    David

  2. #2
    PowerPoster
    Join Date
    Mar 2002
    Location
    UK
    Posts
    4,780

    Re: Paste into multiple textboxes at once

    In your case you are not using tabs but CrLf (new lines).

    I wont give you any code but spell out how you could do this.

    First your textbox has change events. So if a user types (or pastes) something into the first box you are told about it.
    Next up, the info that is pasted should all go into the text box, so using your event you can extract the info from the textbox and 'split' it into seperate strings
    With your seperate strings you can now decide where each one will go

    Now that is one method based on your concept, however there is another easier method.
    Add a button that fills your form based on the clipboard.
    The button can check the clipboard for text, split out the data and fill each of your textboxes with the relevant part.

  3. #3
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: Paste into multiple textboxes at once

    If your not allowed to change the code then you wont be able to do it.

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Nov 2009
    Posts
    16

    Re: Paste into multiple textboxes at once

    thanks for your response Grimfort.
    But like Joacim says, i am not allowed to change the form that I want to paste onto.

    I somehow want to manipulate the copied data to include the Tab character after each value, so when i click paste, the tab character forces the cursor to jump to the next textbox and paste the rest etc.

    I need to know if there is such a tab character that will do this.

    (I do not want to use it in this manner, but i have seen user created serialkey-generators that autofills textboxes on a different form, and they did not alter the form which is pasted on.)

    I hope i am making sense.

  5. #5
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: Paste into multiple textboxes at once

    No, even if you would change the content of the clipboard to include tab characters those will not cause the focus to be changed between different controls when you paste. It's the actual physical event that you press the tab key on your keyboard which is intersepted by Windows and unless the focused control swallows tab strokes is translated to the correct messages to switch focus so it really has nothing todo with the character itself. When you paste text from the clipboard no actual key events is fired (except maybe for Ctrl+V or Shift+Ins if that is used to do the pasting).

    You must add that logic to the application itself. Just like the add-in for a webbrowser you mentioned that change the behavior of the browser itself. So unless your window form application have the ability to accept plug-ins you can only do this by altering the source of the original project.
    Last edited by Joacim Andersson; Aug 23rd, 2010 at 07:06 AM.

  6. #6

    Thread Starter
    Junior Member
    Join Date
    Nov 2009
    Posts
    16

    Re: Paste into multiple textboxes at once

    I think i have found my solution here :

    http://www.dailydoseofexcel.com/arch...l-application/

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width