• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 298
  • Last Modified:

Basic Context Menu/Toolstrip Edit Functions in VS 2005

Hello,

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()
-or-
CType(CType(sender, MenuItem).GetContextMenu.SourceControl, TextBox).Copy()
etc...

What would the equivalent code in VS 2005 be?

Thanks,
-Torrwin
0
Torrwin
Asked:
Torrwin
  • 2
1 Solution
 
Bob LearnedCommented:
It's been too long for 2003 now, so what are you trying to do?  Are you using a ContextMenuStrip?

Bob
0
 
TorrwinAuthor Commented:
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.
0
 
Bob LearnedCommented:
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)
    txt.Paste()
  End Sub

Bob
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now