|
-
Aug 20th, 2010, 09:42 AM
#1
Thread Starter
Junior Member
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
-
Aug 20th, 2010, 10:15 AM
#2
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.
-
Aug 20th, 2010, 12:01 PM
#3
Re: Paste into multiple textboxes at once
If your not allowed to change the code then you wont be able to do it.
-
Aug 23rd, 2010, 06:48 AM
#4
Thread Starter
Junior Member
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.
-
Aug 23rd, 2010, 06:57 AM
#5
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.
-
Aug 23rd, 2010, 07:27 AM
#6
Thread Starter
Junior Member
Re: Paste into multiple textboxes at once
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|