473,387 Members | 1,678 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Cutting and Pasting

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

Nov 15 '05 #1
1 1314
Use textbox1.paste(), that will do the work, no other code is needed

HTH
Kalpesh

"Abe Frohnman" <us******@SPAMexperimentzero.org> wrote in message
news:fx**********************@news.easynews.com...
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

Nov 15 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Liberal | last post by:
I am looking for the simplest forum, bbs script which has those features? new messages will be displayed only after the administrator reviewed allow users post without signing up display the...
2
by: ccll20022000 | last post by:
Just curious. I am writing a description for a site I want developers to build (mostly in flash) I was wondering if it is possible to prevent pasting into a field Thanks! ccll20022000
3
by: Michael Shell | last post by:
Greetings, Consider the XHTML document attached at the end of this post. When viewed under Firefox 1.0.5 on Linux, highlighting and pasting (into a text editor) the <pre> tag listing will...
3
by: Wessi | last post by:
Hi, token pasting means, that normally whitespaces and comments are deleted before and after the ## operator. I want the preprocessor to hold an existing whitespace while replacing the argument...
13
by: Henry Townsend | last post by:
I hope this is on-topic in c.l.c - it's about the C preprocessor more than the language per se, more generally about the K&R behavior, and most specifically about the Sun cpp which is why I've...
1
by: Grant Smith | last post by:
I've got an application that I can copy some text out of the RichTextBox control. I would like to keep the formatting so I'm able to copy it to the Clipboard with RTF formatting. I have no...
8
by: Paul | last post by:
Hi all, I'm probably missing something obvious here, but occasionally the response stream for pages on my site is cutting off leaving incomplete HTML and an ugly page. Response.Buffer is set...
5
by: exhuma.twn | last post by:
As many might know, windows allows to copy an image into the clipboard by pressing the "Print Screen" button on the keyboard. Is it possible to paste such an image from the clipboard into a "Text"...
2
by: mark.bergman | last post by:
I am porting some old code from Digital Unix to Linux using token pasting, which is failing to compile (code simplified): #define DEBUG(strg,v) printf("debugoutput: "##strg##".\n", v); main()...
1
by: jeff | last post by:
Given: ===Program <=== $ cat macro_delay_expansion.c #define args(a,b) a, b #define myprintf(a, b, c) do { \ printf("%d %d %d\n", a, b, c );\ } while(0)
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.