472,127 Members | 2,051 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

Cut / Copy / Paste ????

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 via the file menu events using the clipboard. However, what I don't get is how is the program able to produce a context menu in the textbox area. When right clicking, the context pops up and allows to cut/copy/paste/delete, etc..

But the thing is, I don't see a context menu assigned to txtPaste in Visual Studio properties box. Even then, when I search for the cut/copy/paste code, I come up short. Nothing. What kind of magic is this? I know of the textbox.copy(), textbox.cut(), textbox.paste() functions for a textbox control box. But I don't see this being used at all

Even then, I tried viewing other sample codes to see if any code pops up screaming at me here I am. But no. Same thing. There's no site of the right click context menu with the cut/copy/paste selection. Am I missing something here? I want to get in on the secret invisible coding that allows cut/copy/paste

I was wondering if there exists a much quicker way to implement cut/copy/paste without going through the entire windows form's textboxes and manually creating each cut/copy/paste function. That sounds the stupid and hardway. There must be an easier way... Looks like the Using the Clipboard sample code does such thing (along with other code samples I've looked at), without showing a lot of coding for cut/copy/paste events

Help?
Nov 16 '05 #1
4 21391
Legendary Pansy wrote:
[...]
But the thing is, I don't see a context menu assigned to txtPaste [...]


I think you're asking why text boxes provide a context-menu which allows
one to cut, copy and paste without any coding required.

Well, text boxes automatically provide a context-menu which allows the
user to undo, cut, copy, paste, delete and select all. When you use a
text box, you automatically get all this functionality with it.
Nov 16 '05 #2
Thanks for the reply C# Learner. You're right. It is automatically generated. Sweet, less coding for me. So I'll turn to my next problem: is there a quick way to do the richtextbox or do I have to manually code that in? When I placed the textbox, I can see it generated the context menu automatically. That's great. But when I put in the richtextbox, there's no context menu. Although the richtextbox doesn't have context menu, the functionality of cut/copy/paste exists from Ctrl+X, Ctrl+C, Ctrl+V

Is there a quick way to generate the context menu that the textbox has for richtextbox or do I have to emulate it and code in the context menu myself

Thanks.
Nov 16 '05 #3
Legendary Pansy wrote:
[...]
Is there a quick way to generate the context menu that the textbox has for richtextbox
or do I have to emulate it and code in the context menu myself?
[...]


Yeah, I believe you'll have to do it manually, with a RichTextBox.

You can use a ContextMenu component, assign the reference to
RichTextBox.ContextMenu, then respond to the ContextMenu click events,
calling RichTextBox.Cut, RichTextBox.Copy, etc.
Nov 16 '05 #4
Thanks for your input. Appreciate it.
Nov 16 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Rachel Suddeth | last post: by
2 posts views Thread by Matt | last post: by
7 posts views Thread by lgbjr | last post: by
6 posts views Thread by Ben R. | last post: by
17 posts views Thread by Steve | last post: by

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.