Hi,
When creating a popup menu I find it rather difficult to provide the
eventhandler for the MenuItem with enough information. My actual problem is
that I create a popup menu with a list of objects of which one, by clicking
the item, must be assinged to another object. I use the same eventhandler for
all the menuitems in the popup menu as the objects listed in the popup menu
is of arbitrary length. To correlate the 'sender' menuitem in my eventhandler
with its corresponding object, I use menuitem.Index to get the position of
the menuitem in the popup window and then can deduct the position of the
corresponding object in an arraylist. It seems wrong to to it this way, I'm
so much missing the Tag field for menuitems....
Having any suggestions to a better way, please PLEASE reply on this.
Than you very much. Best regards Jesper, Denmark. 4 2276
Hi Jesper,
I am not so into UI programming, but as a first thought, you make your own
derived version of MenuItem, and then add a property to it for accessing the
object.
Is that a valid solution for you?.
"Jesper" <Je****@discussions.microsoft.com> wrote in message
news:A2**********************************@microsof t.com... Hi,
When creating a popup menu I find it rather difficult to provide the eventhandler for the MenuItem with enough information. My actual problem
is that I create a popup menu with a list of objects of which one, by
clicking the item, must be assinged to another object. I use the same eventhandler
for all the menuitems in the popup menu as the objects listed in the popup
menu is of arbitrary length. To correlate the 'sender' menuitem in my
eventhandler with its corresponding object, I use menuitem.Index to get the position of the menuitem in the popup window and then can deduct the position of the corresponding object in an arraylist. It seems wrong to to it this way,
I'm so much missing the Tag field for menuitems....
Having any suggestions to a better way, please PLEASE reply on this.
Than you very much. Best regards Jesper, Denmark.
Hi Jesper,
The MenuItem class doen not derive from the Control class and hence doesn't
have the Tag property.
Though extending the menuitem class is a solution, i don't know whether this
would affect usability thru the designer in any way.
Another solution would be to use the Hashtable to store the text of the menu
items and then find out which menu item was invoked - yes it isn't very
'graceful' :).
HTH
- Rakesh Rajan
"Jesper" <Je****@discussions.microsoft.com> wrote in message
news:A2**********************************@microsof t.com... Hi,
When creating a popup menu I find it rather difficult to provide the eventhandler for the MenuItem with enough information. My actual problem
is that I create a popup menu with a list of objects of which one, by
clicking the item, must be assinged to another object. I use the same eventhandler
for all the menuitems in the popup menu as the objects listed in the popup
menu is of arbitrary length. To correlate the 'sender' menuitem in my
eventhandler with its corresponding object, I use menuitem.Index to get the position of the menuitem in the popup window and then can deduct the position of the corresponding object in an arraylist. It seems wrong to to it this way,
I'm so much missing the Tag field for menuitems....
Having any suggestions to a better way, please PLEASE reply on this.
Than you very much. Best regards Jesper, Denmark.
"Rakesh Rajan" <ra**********************@hotmail.com> wrote: Though extending the menuitem class is a solution, i don't know whether this would affect usability thru the designer
It would. A newly written inherited class isn't automatically usable
in the Designer.
Another solution would be to use the Hashtable to store the text of the menu items and then find out which menu item was invoked - yes it isn't very 'graceful' :).
Menu items can share captions, or change their captions at run time,
so it would be smarter to use the MenuItems themselves (reference
types) as keys in the HashTable.
P.
Thanks, good idea, it works fine, problem solved.
Best regards Jesper
"Paul E Collins" wrote: "Rakesh Rajan" <ra**********************@hotmail.com> wrote:
Though extending the menuitem class is a solution, i don't know whether this would affect usability thru the designer
It would. A newly written inherited class isn't automatically usable in the Designer.
Another solution would be to use the Hashtable to store the text of the menu items and then find out which menu item was invoked - yes it isn't very 'graceful' :).
Menu items can share captions, or change their captions at run time, so it would be smarter to use the MenuItems themselves (reference types) as keys in the HashTable.
P. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Rakesh |
last post by:
Hi,
I am able to obtain a MenuItem object's Name property @
design-time, but am not able to get the same @ run-
time...why?
And since MenuItem doesn't inherit from Control class,
it's not...
|
by: Marcel |
last post by:
Hi,
the application I am writing has a MainMenu and a DataGrid
(UltraGrid).
Now I have to edit the text of each cell in this grid. So far so good.
All works fine in editmode but if I press a...
|
by: Claus Holm |
last post by:
I'm trying to enable a menuitem in the parent form from a mdichild. Rather
than making the menuitems public, I'd go for a public method in the parent
form to do the change, but when I call the...
|
by: Eric Sabine |
last post by:
I've simplified the code to the following. I'm just overlooking something
very simple I'm sure.
Dim mic() As MenuItem
mic = New MenuItem(3) {}
mic(0) = New MenuItem("a")
mic(0).Index = 1
...
|
by: Eric Sabine |
last post by:
Basically, the following code creates a menuItem array and tries to use it
twice. In the following piece of code, only the line that appears second
gets used. The first becomes ignored presumably...
|
by: Jeff Mason |
last post by:
I have an application where I need to set certain menu items invisible based on a
user privilege.
We did a sinmlar thing in VB6 and used the menu item's tag property to assign an
identifier to...
|
by: Jeff Mason |
last post by:
I have an application where I need to set certain menu items invisible based on a
user privilege.
We did a sinmlar thing in VB6 and used the menu item's tag property to assign an
identifier to...
|
by: Agnes |
last post by:
I know how to get the Menuitem's TEXT . BUT I need to get the names , Does
anyone know how to do ??
Thanks
I try That " For Each FileMenuItem As MenuItem In Me.Menu.menuitem" before
|
by: polocar |
last post by:
Hi,
I'm writing a program using Visual C# 2005 Professional Edition, and
I was trying to assign multiple MainMenu objects (one by one, of
course) to the same Form (let's suppose 2 MainMenu...
|
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...
|
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...
|
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:
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...
| |