By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,659 Members | 1,957 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,659 IT Pros & Developers. It's quick & easy.

Cut / Copy / Paste ????

P: n/a
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
Share this Question
Share on Google+
4 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
Thanks for your input. Appreciate it.
Nov 16 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.