|
-
Oct 11th, 2021, 11:57 AM
#1
Copying and Pasting in a DGV
I decided to break another thread I just created by doing a copy and paste action on a DGV. As it turns out, that's a bit fiddly, too. If I just click in a cell and press Ctrl+C, I get an internal exception about a method not being implemented. If I highlight JUST the text in the cell, the Ctrl+C works fine.
This appears to be more or less understood. Copying the whole cell is problematic, but copying the value in the cell is not. However, this is not intuitive to the user, and it means that pasting into multiple cells is not even possible without doing a bit more work.
I believe that I can handle the KeyDown event to check for Ctrl+C, then also check for Ctrl+V, and get the behavior people would expect, but people are weird, so this won't always work. People expect that a cell in a DGV is it's contents, so they expect to be able to select a cell and copy and paste it. Lots of people know Ctrl+C/Ctrl+V, but I'm always surprised at the number that right click and select Copy, then select Paste, which would certainly break the KeyDown approach. People also aren't going to understand the idea of selecting the contents of a cell rather than the whole cell, so that's kind of a non-starter to begin with.
For these reasons, the official MS means for copying and pasting in a DGV seem to be out of consideration. Before I go build my own grid to get around this (I've done it before, I'll do it again if I have to), I was wondering whether anybody has a way to do copying and pasting in a DGV that works the way people would expect it to?
My usual boring signature: Nothing
 
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
|