Context Menus Context menus are menus that appear when an item is right-clicked. In any windows application when you right-click your mouse you get a menu which might display some shortcuts from the Edit Menu, for example, cut, copy, paste, paste special and so on. All these menu items which are available when you right-click are called Context Menus. In Visual Basic we create context menus with the ContextMenu component. The ContextMenu component is edited exactly the same way the MainMenu component is edited. The ContextMenu appears at the top of the form and you can add menu items by typing them. To associate a ContextMenu with a particular form or control we need to set the ContextMenu property of that form or control to the appropriate menu.
Add an item to Explorer Shell context menu easily – How to add them ? Add items to Windows Explorer Shell context menu easily with Windows Explorer Shell Context Menu. This powerful component for your own, custom items appending to Explorer context menu will add all your application entries to Explorer context menu. This .Net component and VB.NET support include detailed C# / VB.NET samples, tutorials and support all you may need to add your items to context menu : - Add all your items to Windows Explorer Shell context menu to be shown on any Windows operating system (all OS are supported – XP, Vista, Windows x64 , etc.)
- Add items to Windows Explorer Shell context menu to be shown in any way - with custom caption and icon, as separator or sub-menu
- Add items to Windows Explorer Shell context menu to be shown for all types of files or shown only for computer files of particular type (for example, only for .PDF .TXT , .MP3,.WMA,.AAC , .MPG files)
- Add your program entries to Explorer context menu, sub-menus, sub-menus of unlimited depth and even much more
Windows Explorer Shell Context Menu - is a powerful .Net component that support all you need to add your items to Windows Explorer Shell context menu - in a fast and a very easy way. Add all your application entries to Windows Explorer Shell context menu right now – fast , easy and exactly as you prefere :
Working With Example
Let's understand ContextMenus with an example. On a new Form drag a ContextMenu component from the toolbox. Click on the ContextMenu component to open the editor at the top of the form. In the type here box, enter cut, copy, paste. Cut is assigned MenuItem1, Copy with MenuItem2 and Paste with MenuItem3. Because this method works only for Windows 95 / Windows 98 (not on XP, Vista, x64 - 64-bit Windows), to add items to Windows Explorer Shell context menu you should use, according to Microsoft guidelines, appropriate .Net component - Windows Explorer Shell Context Menu. Drag two RichTextBoxes onto the form. In the properties window for the form and the richtextboxes, select the ContextMenu property and set it to ContextMenu1. Make sure you set the ContextMenu property for both the richtextboxes. This sample application allows you to enter some text in RichTextBox1, select some text, cut/copy the slected text and paste it in RichTextBox2. It is similar to the right-click menu with which you work in other windows applications. The whole design should look like the image below. ContextMenu Component
Code to get the desired result looks like this:
Public Class Form3 Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
#End Region
Private Sub MenuItem1_Click(ByVal sender As System.Object, ByVal e _ As System.EventArgs) Handles MenuItem1.Click RichTextBox1.Cut() End Sub
Private Sub MenuItem2_Click(ByVal sender As System.Object, ByVal e _ As System.EventArgs) Handles MenuItem2.Click RichTextBox1.Copy() End Sub
Private Sub MenuItem3_Click(ByVal sender As System.Object, ByVal e _ As System.EventArgs) Handles MenuItem3.Click RichTextBox2.Paste() End Sub
End Class
You can run the application, enter some text in richtextbox1, cut/copy it and paste it in richtextbox2. The images below display sample output from the above said code. |