Quote:
The last block of code :
if (textBoxMovieName.SelectionLength > 0 && keyCode == (Keys.Control & Keys.C))
is not working correctly. If Im | instead of &&, it works when selection is >0 but whatever keypress. If I want to get the exact Ctrl+C from this line... is not working at all... any ideas?
Always start with the debugger: put a breakpoint on the line, and when it hits look at the value of
keyCode
. You will find that it doesn't match
Keys.Control & Keys.C
because
&
is a binary AND operation: Since
Keys.<any key you can press>
does not include the
Keys.Control
bitfield, the result will ALWAYS by zero. You need
Keys.Control | Keys.C
in order to match both.