Copy Paste Function

  • Thread starter Thread starter BD
  • Start date Start date
B

BD

I would like to use the keyboard shortcut 'ctrl + v' to paste from the
clipboard. I can't seem to figure out how to capture the keyboard
input to accomplish this. Any help is greatly appreciated.

Thanks,

BD
 
What are you pasting to? I believe Ctrl-V works for textual input on
controls that include such.

-Drew
 
In an inherited control you usually override ProcessCmdKey and check the
input and clipboard there.

/claes
 
In an inherited control you usually override ProcessCmdKey and check the
input and clipboard there.

/claes

That is what I thought. I would have to process a keydown event and
link it to a keypress event without typing the letter v. How would I
code for that?
 
BD said:
That is what I thought. I would have to process a keydown event and
link it to a keypress event without typing the letter v. How would I
code for that?

Uhm, no you don't, KeyDown is enough.

private void control_KeyDown(object sender, KeyEventArgs e)
{
if(e.Control && e.KeyCode == Keys.V)
{
//Do your stuff here
}
}

So I'm guessing that this is not in an inherited control then but rather
from any general control?

/claes
 
Uhm, no you don't, KeyDown is enough.

private void control_KeyDown(object sender, KeyEventArgs e)
{
if(e.Control && e.KeyCode == Keys.V)
{
//Do your stuff here
}

}

So I'm guessing that this is not in an inherited control then but rather
from any general control?

/claes

Sorry for replying so late, my visual studio crashed. Yes it is just
a general control (multi line textbox). What I was trying to do was
ctrl-C from another program (say email) and do ctrl-v in my C#
application. I will try the above. I was successful at trapping the
ctrl key and pasting but that breaks routine for what is generally
done. Don't want to confuse my users any more than they are, ha ha.

Brian
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top