02-17-2009 02:59 PM
02-17-2009 03:31 PM
A table control is a 2D array of strings. Thus, you have to work within the rules of how to add elements to a 2D array. The primary rule is that it must always be rectangular. The default paste action on a table control will try to insert rows/columns depending on the contents of the clipboard. Thus, if your initial table 2 contained no data, and you tried to paste two cells, they would end up at the top-left corner, not in rows 4 and 5. Even if there were data already present (or just blank cells, which would be empty strings), the paste would not overwrite the contents - it would insert rows/columns.
This means you need to override the way the paste works. The easiest way to do this is with an event structure, and you handle the target table control's "Shortcut Menu Selection (App)" event. Here you can use the Point to Row Column method to get the row/column where the cursor was located. Then, you can determine whether to use Replace Array Subset or Insert Into Array to replace the cell contents, or add new ones if the user is pasting beyond the 2D array contents.