title: Copy/Paste in Windows Forms with custom controls
body: <p>I am writing a small application in C# using <a href="http://en.wikipedia.org/wiki/Windows_Forms" rel="nofollow noreferrer">Windows Forms</a>. I want to let my users copy and paste data around the application and there are some custom controls, for example one is a colour picker.</p>
  
  <p>Some of the default controls (well at least the TextBox) have a copy and paste functionality already. I want to have the same thing with my colour picker, and also want an 'Edit' menu at the top to copy and paste.</p>
  
  <p>At the moment, I can't see how to do this in a nice way, my current tack is to catch the <kbd>Ctrl</kbd> + <kbd>C</kbd> and <kbd>Ctrl</kbd> + <kbd>V</kbd> commands and the menu clicks and go through a function which uses some <a href="http://en.wikipedia.org/wiki/Windows_API" rel="nofollow noreferrer">Win32</a> calls to find the focused control and then copy or paste data from or to the control (with a massive <code>if</code> statement depending on the type of the focused control).</p>
  
  <p>The alternative seems to be to write key handling into every custom control, but with this method I'm not sure how to incorporate the Edit menu functions.</p>
  
  <p>How do I do this in an elegant or more 'standard' way?</p>