April 21st, 2012, 05:21 AM
Copy clipboard to memo field
I have a memo field on my form. I copy lets say 5 records with 5 culums. Firstly i right click on the memo field then click on past.I get what i want but now i see my 5 colums with spaces in between them.I cannot loop through the memo and look for spaces as the fields in it self may have spaces. i want to validate each column and then put it in my database.
how can i achieve this? Then is there a way with a click of a button to put what i have in the clipboard into the memo field?
April 22nd, 2012, 07:35 PM
Seems to me that you need to look at the application from which you are copying the records
and see if it offers any options for specifying the field separators, so that you can set it to something that will
not be contained within your field data.
See if you have an option to replace the <SPACE> character with ~ or |
Alternatively, does it offer a fixed field length option so that you can count characters then trim
leading/trailing spaces as appropriate?
Simple. When you detect a paste operation, retrieve the text content of Clipboard object to a temporary container (can be a simple string variable or a TStrings instance), do your processing (e.g. removing unneeded spaces), then insert the result to your memo field.
Originally Posted by icuras
To reliably intercept the pasting operation, you must handle WM_PASTE message in your memo control. So either you subclass your memo control, or create a child class from it where you could handle WM_PASTE.
I may be wrong; but I think you are missing the problem.
As I read the question, the issue is not how to paste, it is how to differentiate between spaces that represent
column separators and spaces that are part of a column's content.
Perhaps Icuras will confirm if he/she has not already found a solution.
Yes, you are wrong. I am not missing the problem.
Originally Posted by clivew
What the OP wants is how to remove unneeded spaces from the pasted value since he/she can't do that in the memo control. Let me quote the part that says so.
So the solution is simple. If you can't process the clipboard content after it is pasted in the memo, then you process the clipboard content before you paste to the memo. Simple logic, right?
While I admire your self confidence I do not share your interpretation.
Thanks, but I don't care about your interpretation.