Basic Context Menu/Toolstrip Edit Functions in VS 2005

Posted on 2007-07-26
Last Modified: 2013-11-26

I am trying to update my VS 2003 project to VS 2005 and am having a little trouble with the basic edit functions (cut, copy, paste, etc) that I used to use a context menu to accomplish.  In the event handler is the code:

CType(CType(sender, MenuItem).GetContextMenu.SourceControl, TextBox).Cut()
CType(CType(sender, MenuItem).GetContextMenu.SourceControl, TextBox).Copy()

What would the equivalent code in VS 2005 be?

Question by:Torrwin
    LVL 96

    Expert Comment

    by:Bob Learned
    It's been too long for 2003 now, so what are you trying to do?  Are you using a ContextMenuStrip?

    LVL 13

    Author Comment

    Yes, i'm using a ContextMenuStrip.  I'm trying to implement the basic cut, copy, paste functions on the textboxes.

    Basically, the code above gets the name of the textbox which the context menu was used on, and performs the function on that textbox.
    LVL 96

    Accepted Solution

    Something like this should work:

      Private Sub PasteToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PasteToolStripMenuItem.Click
        Dim item As ToolStripItem = CType(sender, ToolStripItem)
        Dim parent As ContextMenuStrip = item.Owner
        Dim txt As TextBox = CType(parent.SourceControl, TextBox)
      End Sub


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (…
    This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now