Cutting and Pasting

  • Thread starter Thread starter Abe Frohnman
  • Start date Start date
A

Abe Frohnman

Hey all,

I have another task I'm trying to find the solution for. I have a text
box that I want to cut and paste text into, from a menu. This is the
code I have so far:

private void menuItem6_Click(object sender, System.EventArgs e)
{
if (textBoxDescription.ContainsFocus)
{
IDataObject dd = Clipboard.GetDataObject();
if (d.GetDataPresent(DataFormats.Text))
textBox1.Text = d.GetData(DataFormats.Text).ToString();
}
}

The problem with this is that it replaces *everything* in the text box
with the contents of the clipboard. What I want it to do is to insert
the text wherever the cursor is at, or whatever text may be highlighted.
Any advice?

AF
 
Use textbox1.paste(), that will do the work, no other code is needed

HTH
Kalpesh
 

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