473,385 Members | 1,528 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Create contextmenustrip on run time

slapshock
Good day, please help me on my problem....

i want to create a context menu strip on run time but i got this error, please help me, i tried to search on the net but i cant fine any solution there...

my code is:
Expand|Select|Wrap|Line Numbers
  1. Imports System.ComponentModel.CancelEventArgs
  2. Public Class VinteryBase
  3.     Private m_New As Boolean
  4.     Sub CreateMenu()
  5.         Dim mnuItem As ToolStripMenuItem
  6.  
  7.         If m_New = True Then
  8.             mnuItem = New ToolStripMenuItem("&New")
  9.             AddHandler mnuItem.Click, cms_Opening  >>>>this line is the error
  10.         End If
  11.     End Sub
  12.     Sub cms_Opening(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs)
  13.         ' Acquire references to the owning control and item.
  14.         Dim c As Control = contextMenu.SourceControl
  15.         Dim tsi As ToolStripDropDownItem = contextMenu.OwnerItem
  16.  
  17.         ' Clear the ContextMenuStrip control's 
  18.         ' Items collection.
  19.         contextMenu.Items.Clear()
  20.  
  21.         ' Check the source control first.
  22.         If (c IsNot Nothing) Then
  23.             ' Add custom item (Form)
  24.             contextMenu.Items.Add(("Source: " + c.GetType().ToString()))
  25.         ElseIf (tsi IsNot Nothing) Then
  26.             ' Add custom item (ToolStripDropDownButton or ToolStripMenuItem)
  27.             contextMenu.Items.Add(("Source: " + tsi.GetType().ToString()))
  28.         End If
  29.  
  30.         ' Populate the ContextMenuStrip control with its default items.
  31.         contextMenu.Items.Add("-")
  32.         contextMenu.Items.Add("Apples")
  33.         contextMenu.Items.Add("Oranges")
  34.         contextMenu.Items.Add("Pears")
  35.  
  36.         ' Set Cancel to false. 
  37.         ' It is optimized to true based on empty entry.
  38.         e.Cancel = False
  39.  
  40.     End Sub
  41. End Class

>>>>the error:
Error 2 Argument not specified for parameter 'e' of 'Public Sub cms_Opening(sender As Object, e As System.ComponentModel.CancelEventArgs)'.
Dec 15 '07 #1
1 5084
kenobewan
4,871 Expert 4TB
Maybe you are using addhandler but not specify the arguments?
Dec 15 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Jake | last post by:
I'm having a problem with the ContextMenuStrip object when using it on a NotifyIcon while the taskbar is at the top of the screen. Problem: The context menu will draw above the top of the...
7
by: Dave | last post by:
How do I get my ContextMenuStrip to receive key down preview events? I have the event hooked but I don't see the key strokes in the event? Dave
5
by: =?Utf-8?B?cHJvZ2dlcg==?= | last post by:
I've written an application that can minimize to the tray and can reappear if you double click on the icon in the tray (ShowInTaskbar is set to false). I've also created a ContextMenuStrip (Visual...
0
by: active | last post by:
For the last 3 or 4 days I've been, on an off, searching the Internet and theVS2005 Doc for an example of how to add a contextmenustrip to a menustrip. I can move all the items from a...
0
by: Viper | last post by:
I added a NotifyIcon to my project and a ContextMenuStrip so that when the taskbar icon is clicked a menu shows up. I added the ContextMenuStrip to the properties menu for the notifyicon. now...
1
by: =?Utf-8?B?QnJhZA==?= | last post by:
i have a menu system that is generated dynamically everything works good except for one minor astetic.... I click on a menu item that displays a ContextMenuStrip Popup Menu If an item on...
0
by: Tark Siala | last post by:
Hi I have ListView include customers (foe example), and connected to "ContextMenuStrip" include (Edit Customer, Delete Customer, ...), when user right click on any Customer Item in ListView...
9
by: =?Utf-8?B?Z2luYWNyZXNzZQ==?= | last post by:
Hi, I have a form (Form1) with a ContextMenuStrip (ContextMenuStrip1). If I pass Form1 to a Utility Sub with the following code: Public Sub Utility(theForm as Object) with theForm For Each...
2
by: eBob.com | last post by:
I've been working on an app which has an array of RichTextBoxes. And I have a context menu for the RTBs. The context menu has two levels; the first level has two items, "Load Sample Text File"...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.