473,419 Members | 1,822 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,419 software developers and data experts.

Copy, Cut, Paste

Hi

How can I implement cut or copy or paste in code?

Thanks

Regards
Nov 20 '05 #1
13 2371
Hi, this is a very broad question... Please tell us what you'd like to
Cut/Copy/Paste...

e.g. Files/Images/Text/etc

--
HTH,
-- Tom Spink, Über Geek

Woe be the day VBC.EXE says, "OrElse what?"

Please respond to the newsgroup,
so all can benefit
"John" <jo**@nospam.infovis.co.uk> wrote in message
news:u6**************@tk2msftngp13.phx.gbl...
Hi

How can I implement cut or copy or paste in code?

Thanks

Regards

Nov 20 '05 #2
Sorry, I just want to provide the Edit menu's copy, cut paste functionality.

Thanks

Regards
"Tom Spink" <thomasdotspinkat@ntlworlddotcom> wrote in message
news:O4**************@TK2MSFTNGP11.phx.gbl...
Hi, this is a very broad question... Please tell us what you'd like to
Cut/Copy/Paste...

e.g. Files/Images/Text/etc

--
HTH,
-- Tom Spink, Über Geek

Woe be the day VBC.EXE says, "OrElse what?"

Please respond to the newsgroup,
so all can benefit
"John" <jo**@nospam.infovis.co.uk> wrote in message
news:u6**************@tk2msftngp13.phx.gbl...
Hi

How can I implement cut or copy or paste in code?

Thanks

Regards


Nov 20 '05 #3
"John" <jo**@nospam.infovis.co.uk> schrieb

How can I implement cut or copy or paste in code?

System.Windows.Forms.Clipboard.*
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #4
If I want to implement it in the generic way (Edit->Copy) what would be the
value of data in System.Windows.Forms.Clipboard.SetDataObject(data) ?
Thanks

Regards
"Armin Zingler" <az*******@freenet.de> wrote in message
news:%2*****************@TK2MSFTNGP12.phx.gbl...
"John" <jo**@nospam.infovis.co.uk> schrieb

How can I implement cut or copy or paste in code?

System.Windows.Forms.Clipboard.*
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #5
Hi, what do you want in there?

--
HTH,
-- Tom Spink, Über Geek

Woe be the day VBC.EXE says, "OrElse what?"

Please respond to the newsgroup,
so all can benefit
"John" <jo**@nospam.infovis.co.uk> wrote in message
news:#1*************@TK2MSFTNGP12.phx.gbl...
If I want to implement it in the generic way (Edit->Copy) what would be the value of data in System.Windows.Forms.Clipboard.SetDataObject(data) ?
Thanks

Regards
"Armin Zingler" <az*******@freenet.de> wrote in message
news:%2*****************@TK2MSFTNGP12.phx.gbl...
"John" <jo**@nospam.infovis.co.uk> schrieb

How can I implement cut or copy or paste in code?

System.Windows.Forms.Clipboard.*
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html


Nov 20 '05 #6
Whatever test the user has selected at the time (it is a database app). I
would not know which field it would be beforehand.

Thanks

Regards

"Tom Spink" <thomasdotspinkat@ntlworlddotcom> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Hi, what do you want in there?

--
HTH,
-- Tom Spink, Über Geek

Woe be the day VBC.EXE says, "OrElse what?"

Please respond to the newsgroup,
so all can benefit
"John" <jo**@nospam.infovis.co.uk> wrote in message
news:#1*************@TK2MSFTNGP12.phx.gbl...
If I want to implement it in the generic way (Edit->Copy) what would be

the
value of data in System.Windows.Forms.Clipboard.SetDataObject(data) ?
Thanks

Regards
"Armin Zingler" <az*******@freenet.de> wrote in message
news:%2*****************@TK2MSFTNGP12.phx.gbl...
"John" <jo**@nospam.infovis.co.uk> schrieb
>
> How can I implement cut or copy or paste in code?
System.Windows.Forms.Clipboard.*
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html



Nov 20 '05 #7
"John" <jo**@nospam.infovis.co.uk> schrieb
Whatever test the user has selected at the time (it is a database
app). I would not know which field it would be beforehand.


You can get the active Form using Form.ActiveForm or ActiveMdiChild in an
Mdi container. The ActiveControl returns the active control, and depending
on the type of the active control you can copy the selected text or
whatever. For example, if the active control is a Datagrid, you can copy the
selected text of the active cell.

In all Forms I'd probably implement an Interface that handles the clipboard
features for the Form.
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #8
* "John" <jo**@nospam.infovis.co.uk> scripsit:
How can I implement cut or copy or paste in code?


For example, for the RichTextBox:

<http://www.mvps.org/dotnet/dotnet/samples/controls/downloads/RichTextBoxContext.zip>

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #9
when I right click in a text field it gives me the cut/copy/paste context
menu. cannot I tap into this built-in functionality?

Regards

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:bu************@ID-208219.news.uni-berlin.de...
* "John" <jo**@nospam.infovis.co.uk> scripsit:
How can I implement cut or copy or paste in code?
For example, for the RichTextBox:

<http://www.mvps.org/dotnet/dotnet/sa...RichTextBoxCon
text.zip>
--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>

Nov 20 '05 #10
"Armin Zingler" <az*******@freenet.de> schrieb
"John" <jo**@nospam.infovis.co.uk> schrieb
Whatever test the user has selected at the time (it is a
database app). I would not know which field it would be
beforehand.


You can get the active Form using Form.ActiveForm or ActiveMdiChild
in an Mdi container. The ActiveControl returns the active control,
and depending on the type of the active control you can copy the
selected text or whatever. For example, if the active control is a
Datagrid, you can copy the selected text of the active cell.

In all Forms I'd probably implement an Interface that handles the
clipboard features for the Form.


Some example code for you.... attention: Untested! :)
Public Interface ISupportsClipboard
Enum Action
Copy
Cut
Delete
Paste
End Enum

Function ActionAvailable(ByVal Action As Action) As Boolean
Sub PerformAction(ByVal Action As Action)
End Interface
In the Form, implement ISupportsClipboard:

Public Function ActionAvailable( _
ByVal Action As ISupportsClipboard.Action) As Boolean _
Implements ISupportsClipboard.ActionAvailable

Return TypeOf Me.ActiveControl Is TextBox AndAlso _
DirectCast(Me.ActiveControl, TextBox).SelectionLength > 0 AndAlso _
(Action <> ISupportsClipboard.Action.Paste OrElse _
Clipboard.GetDataObject.GetDataPresent(GetType(Str ing)))

End Function

Public Sub PerformAction( _
ByVal Action As ISupportsClipboard.Action) _
Implements ISupportsClipboard.PerformAction

If Not Me.ActionAvailable(Action) Then
Throw New InvalidOperationException( _
"The clipboard action '" & Action.ToString & "' is not available."
_
)
End If

Dim txt As TextBox
txt = DirectCast(Me.ActiveControl, TextBox)

If Action = ISupportsClipboard.Action.Copy OrElse _
Action = ISupportsClipboard.Action.Cut Then

Clipboard.SetDataObject(txt.SelectedText)
End If

If Action = ISupportsClipboard.Action.Cut OrElse _
Action = ISupportsClipboard.Action.Delete Then
txt.SelectedText = ""
ElseIf Action = ISupportsClipboard.Action.Paste Then
txt.SelectedText =
Clipboard.GetDataObject.GetData(GetType(String)).T oString
End If

End Sub


--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #11
* "John" <jo**@nospam.infovis.co.uk> scripsit:
when I right click in a text field it gives me the cut/copy/paste context
menu. cannot I tap into this built-in functionality?


Please be more specific. What exactly do you want to do for which
type(s) of control(s)?

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #12
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:bu************@ID-208219.news.uni-berlin.de...
* "John" <jo**@nospam.infovis.co.uk> scripsit:
when I right click in a text field it gives me the cut/copy/paste context menu. cannot I tap into this built-in functionality?


Please be more specific. What exactly do you want to do for which
type(s) of control(s)?

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>


I think he is referring to the fact that most windows controls natively
support cut/copy/paste messages - all you have to do is send the appropriate
message with the win32 api. Like this:

http://www.geocities.com/practicalvb...extboxops.html

I'm a bit surprised MS only implements this functionality in
TextBoxBase, and not at a higher level...

Erik
Nov 20 '05 #13
Cor
Hi John,

Strange you did not get this link from Armin, I got it while by looking at
an answer from him

http://msdn.microsoft.com/library/en...ardSupport.asp

I hope this helps?

Cor
Nov 20 '05 #14

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

Similar topics

4
by: Legendary Pansy | last post by:
I was checking out the 101 C# Samples, specifically Windows Forms - Use the Clipboard. I took a look at the code for a while, and I understand what the program is doing with the cut, copy, pasting...
3
by: Rachel Suddeth | last post by:
This may not be the right forum, but it's a problem I chiefly come across when trying to post here. When I do a copy/paste from VS, the text always looks really weird (and even if I'm in an...
2
by: Matt | last post by:
Hello, I have a copy button and a paste button. What code should I add to the copy button and the paste button to do it's work? Thanks, Matt
7
by: lgbjr | last post by:
Hello All, I¡¯m using a context menu associated with some pictureboxes to provide copy/paste functionality. Copying the image to the clipboard was easy. But pasting an image from the clipboard...
0
by: jshoffner | last post by:
This sounds like a really silly question but I'm can't find a solution anywhere. I use the Search window within VS.NET 2003 all the time. However, when I find a sample that is usefull I would like...
5
by: Kaur | last post by:
Hi, I have been successful copying a vba code from one of your posts on how to copy and paste a record by declaring the desired fields that needs to be copied in form's declaration and creating two...
6
by: Ben R. | last post by:
Hi, I've got a vb.net winforms app. Out of the box, I can use Ctrl X, C and V as expected in controls like textboxes. I've got a menustrip, and if I click the link "Add standard items" which...
17
by: Steve | last post by:
I'm trying to code cut, copy, and paste in vb 2005 so that when the user clicks on a toolbar button, the cut/copy/paste will work with whatever textbox the cursor is current located in (I have...
5
by: phill86 | last post by:
Hi I have a main form that holds records for scheduled meetings, date time location etc... in that form i have a sub form that has a list of equipment resources that you can assign to the meeting in...
8
by: jh | last post by:
I'd like to copy/paste into a listbox during runtime. I can do this for a textbox but can't figure out how to accomplish this for a listbox. Any help? Thanks.
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.