Hi there,
I need to add a click handler to a derived menu item class. I am using the
same handler to handle all of the items in the given menu, but need to
derive a new menu item class in order to store a little extra information
for each item.
Previously, I was writing:
MyMenu.MenuItems.Add ( "the text label", New EventHandler(AddressOf
MyMenuItem_Clicked)
where MyMenu_Clicked is the handler to use. Now I want to write:
Dim theItem as new MyMenuItemClass("the text label")
MyMenu.MenuItems.Add ( theItem )
...... --> somehow add the event handler MyMenuItem_Clicked to be the same
for each item in MyMenu.
This is a dynamic menu, so I can't hard-code each one. I notice there isn't
a MenuItems.Add method for MenuItem, EventHandler, although there is one for
String, EventHandler.
Thanks for any help you can give. 4 1589
"Robin Tucker" <id*************************@reallyidont.com> schrieb MyMenu.MenuItems.Add ( "the text label", New EventHandler(AddressOf MyMenuItem_Clicked)
where MyMenu_Clicked is the handler to use. Now I want to write:
Dim theItem as new MyMenuItemClass("the text label")
Add another constructor to your MyMenuItemClass. The 2nd arg takes the event
handler. Call the base class constructor that also takes the event handler.
--
Armin
How to quote and why: http://www.plig.net/nnq/nquote.html http://www.netmeister.org/news/learn2quote.html
Got it, cheers.
"Armin Zingler" <az*******@freenet.de> wrote in message
news:40***********************@news.freenet.de... "Robin Tucker" <id*************************@reallyidont.com> schrieb MyMenu.MenuItems.Add ( "the text label", New EventHandler(AddressOf MyMenuItem_Clicked)
where MyMenu_Clicked is the handler to use. Now I want to write:
Dim theItem as new MyMenuItemClass("the text label") Add another constructor to your MyMenuItemClass. The 2nd arg takes the
event handler. Call the base class constructor that also takes the event
handler.
-- Armin
How to quote and why: http://www.plig.net/nnq/nquote.html http://www.netmeister.org/news/learn2quote.html
* "Robin Tucker" <id*************************@reallyidont.com> scripsit: I need to add a click handler to a derived menu item class. I am using the same handler to handle all of the items in the given menu, but need to derive a new menu item class in order to store a little extra information for each item.
Previously, I was writing:
MyMenu.MenuItems.Add ( "the text label", New EventHandler(AddressOf MyMenuItem_Clicked)
where MyMenu_Clicked is the handler to use. Now I want to write:
Dim theItem as new MyMenuItemClass("the text label")
MyMenu.MenuItems.Add ( theItem )
..... --> somehow add the event handler MyMenuItem_Clicked to be the same for each item in MyMenu.
This is a dynamic menu, so I can't hard-code each one. I notice there isn't a MenuItems.Add method for MenuItem, EventHandler, although there is one for String, EventHandler.
Ctors don't get inherited, so you will have to redefine the ctors you
need (or all of them) and call the base class's ctors inside the ctors
defined in the derived class:
\\\
Public Sub New(...)
MyBase.New(...)
...
End Sub
///
--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Well what I did in the end was this:
Private Sub AddMenuItem(ByVal theText As String, ByVal theData As
MyDataClass)
Dim theNewItem As MyMenuItemWithDataClass = New MyMenuItemWithDataClass
(theText, theData )
AddHandler theNewItem.Click, AddressOf MyMenuItemWithData_Clicked
MyMenu.MenuItems.Add(theNewItem)
End Sub
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:c6************@ID-208219.news.uni-berlin.de... * "Robin Tucker" <id*************************@reallyidont.com> scripsit: I need to add a click handler to a derived menu item class. I am using
the same handler to handle all of the items in the given menu, but need to derive a new menu item class in order to store a little extra
information for each item.
Previously, I was writing:
MyMenu.MenuItems.Add ( "the text label", New EventHandler(AddressOf MyMenuItem_Clicked)
where MyMenu_Clicked is the handler to use. Now I want to write:
Dim theItem as new MyMenuItemClass("the text label")
MyMenu.MenuItems.Add ( theItem )
..... --> somehow add the event handler MyMenuItem_Clicked to be the
same for each item in MyMenu.
This is a dynamic menu, so I can't hard-code each one. I notice there
isn't a MenuItems.Add method for MenuItem, EventHandler, although there is one
for String, EventHandler.
Ctors don't get inherited, so you will have to redefine the ctors you need (or all of them) and call the base class's ctors inside the ctors defined in the derived class:
\\\ Public Sub New(...) MyBase.New(...) ... End Sub ///
-- Herfried K. Wagner [MVP] <URL:http://dotnet.mvps.org/> This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Al Christoph |
last post by:
I have a program that mixes wizard like behavior with random access to the
various dialogs in the wizard. I do this by having each step map to a
toolstripmenuitem. Users can randomly choose the...
|
by: Sakharam Phapale |
last post by:
Hi All,
I am working on a project, where maximum operations carried out on Files and
multi-dimensional arrays. Since array data is huge application takes too
much memory.
My problem is, after...
|
by: maitrepoy |
last post by:
hello
I have to create a small addin which works on Powerpoint, Word, Outlook, and Excel on Office 2000, XP, and 2003.
This addin consists in adding 2 new Buttons in the "File" Menu of office....
|
by: JohnR |
last post by:
In it's simplest form, assume that I have created a usercontrol,
WSToolBarButton that contains a button. I would like to eventually create
copies of WSToolBarButton dynamically at run time based...
|
by: Serious_Practitioner |
last post by:
Good day, and thank you in advance for any assistance. I'm having trouble
with something that I'm trying for the first time.
Using Access 2000 - I want to run a function either on the click of a...
|
by: Ben |
last post by:
Hello
I have frames set up in an asp.net application and need one frame to refresh
another. Seeing as events need to be registered at the time the page is sent
from the server, I was wondering...
|
by: the_grove_man |
last post by:
How do I invoke a "Right-Click" Programmtically?
John
|
by: JDeats |
last post by:
Using VS.NET 2005, if you place a WinForms WebBrowser control on a
form, then place a command button on that form and in the "click" even
handler for the command you do:
webBrowser1.DocumentText...
|
by: Curtis Rutland |
last post by:
OK, I have a question. I have a problem. I'm trying to catch all KeyDown events on a button, but the problem is when I press the "Enter" key, the button's "Click" event is triggered, not the...
|
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,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
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...
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
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...
| |