473,505 Members | 14,618 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Dynamic controls, menuitems, windowlist

YYZ
In my program, a user can open up many different "Loans" -- each one is
loaded into a dynamically created usercontrol (ucLoan) -- in order for
them to be able to switch between the ones they have open, I have added
a Window menu item -- just like in Word or any one of a thousand
different applications.

Each Loan has a unique GUID, and I could easily enumerate all of the
ucLoan controls on the main form and check their GUID property to find
the one that I want...however, the MenuItem object doesn't seem to have
a property I can use to store this guid...no tag, etc. Am I missing
something?

Assuming that that is true, how would any of you go about doing this?
What I really need is a way to associate a menu item with a certain
control on my form -- dynamically, of course. The text of the menu
item needs to be understandable by my users, so I don't want to put a
GUID in the text.

Matt

Feb 3 '06 #1
6 1192

YYZ wrote:
In my program, a user can open up many different "Loans" -- each one is
loaded into a dynamically created usercontrol (ucLoan) -- in order for
them to be able to switch between the ones they have open, I have added
a Window menu item -- just like in Word or any one of a thousand
different applications.

Each Loan has a unique GUID, and I could easily enumerate all of the
ucLoan controls on the main form and check their GUID property to find
the one that I want...however, the MenuItem object doesn't seem to have
a property I can use to store this guid...no tag, etc. Am I missing
something?

Assuming that that is true, how would any of you go about doing this?
What I really need is a way to associate a menu item with a certain
control on my form -- dynamically, of course. The text of the menu
item needs to be understandable by my users, so I don't want to put a
GUID in the text.


Create your own class derived from MenuItem, then you can

a) put in it whatever properties etc you like, eg associated user
control, GUID, whatever
b) since it is derived from MenuItem, it _is_ still a MenuItem, so you
can put it in menus as normal.

--
Larry Lard
Replies to group please

Feb 3 '06 #2
YYZ
> Create your own class derived from MenuItem, then you can

Okay, I admit I'm new to .Net, but holy crap, of COURSE that's what I
should do. Thanks for pointing out so quickly what an idiot I am. <g>

Seriously, thanks -- I can't believe I didn't think of that one on my
own!

Matt

Feb 3 '06 #3
"YYZ" <ma********@gmail.com> schrieb
In my program, a user can open up many different "Loans" -- each one
is loaded into a dynamically created usercontrol (ucLoan) -- in
order for them to be able to switch between the ones they have open,
I have added a Window menu item -- just like in Word or any one of a
thousand different applications.

Each Loan has a unique GUID, and I could easily enumerate all of the
ucLoan controls on the main form and check their GUID property to
find the one that I want...however, the MenuItem object doesn't seem
to have a property I can use to store this guid...no tag, etc. Am I
missing something?

Assuming that that is true, how would any of you go about doing
this? What I really need is a way to associate a menu item with a
certain control on my form -- dynamically, of course. The text of
the menu item needs to be understandable by my users, so I don't
want to put a GUID in the text.

Write a class inheriting from MenuItem and add a property referencing the
Loan object or the ucLoan control. If it references the Loan object - what I
would prefer - keep all ucLoan controls in a Hashtable and use the GUID as
the key. If a menu item is clicked, you have the Loan object, it's GUID and
can retrieve the ucLoan object from the Hashtable.
Armin

Feb 3 '06 #4
YYZ
> Write a class inheriting from MenuItem and add a property referencing the
Loan object or the ucLoan control. If it references the Loan object - what I
would prefer - keep all ucLoan controls in a Hashtable and use the GUID as
the key. If a menu item is clicked, you have the Loan object, it's GUID and
can retrieve the ucLoan object from the Hashtable.


Even better -- no need to enumerate the controls collection looking for
Loan objects.

Thanks Armin and Larry.

Matt

Feb 3 '06 #5
YYZ
> Write a class inheriting from MenuItem and add a property referencing the
Loan object or the ucLoan control. If it references the Loan object - what I
would prefer - keep all ucLoan controls in a Hashtable and use the GUID as
the key. If a menu item is clicked, you have the Loan object, it's GUID and
can retrieve the ucLoan object from the Hashtable.


Okay, I think I'm missing something. When adding a menuitem to a menu,
I have 5 methods to choose from. I think I need a hybrid of 2 of them.
One allows you to add a menuitem by passing an existing menuitem. I
need this to pass my own inherited menuitem class (an actual
instance)...however I also need to have an event handler, too. Which I
can't do with the built-in add menuitem methods.

How do I assign an event handler to an object at run time? I tried
searching on this, but I think I don't know the terms to search
for...any pointers?

Thanks.

Matt

Feb 3 '06 #6
YYZ
Okay, I'm very sorry. It helps when you spell eventhandler correcly.
Here is what I'm doing:

dim oTest as clsMenuItem
oTest = new clsMenuItem
oTest.LoanGuid = sGuid
oTest.Text = "Testing" & sGuid
mnuWindow.MenuItems.Add(oTest)

AddHandler oTest.Click, AddressOf WinListClick

Haven't tested it yet, but I wanted to short-circuit anyone who might
answer with the obvious solution.

Matt

Feb 3 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
4745
by: Eddie de Bear | last post by:
Hi, A project I am working on has a requirement for dynamic menus. For the most part this works really well. The menus I'm creating a based on files and directories, so naturally the menu...
0
1338
by: Deutsche Dogge | last post by:
Hi. I'M having a weird problem with addign menuitems to a menu dynamically on the popup event of the menuitem containing the container of the menuitems i wanna add (tools -> external -> {list of...
1
2512
by: Martin Falta | last post by:
Hi all, I need a help with following problem. I need to create a menu from dynamic loaded assembly on the main form of my application. The menu is created succesfully, but the events of this...
6
2566
by: Ed Sutton | last post by:
I am dynamically appending to a context menu when user right mouse clicks on a treeView. The first time I right-mouse click I see the appended menu. Subsequently, the menu items I append do not...
4
1567
by: Matthew Speed | last post by:
I am developing an MDI database access app that will be used by people with varying access rights. Is it possible to make menu items show or be hidden based upon the authority of the user? ...
0
929
by: Peter Osawa | last post by:
Hi, I'm trying to make a dynamic menu loading menuitems from a db. I managed to do this: Dim mnuPrincipal As New MainMenu For intContador = 0 To 5 Dim mnuItem As New clsMenuItem
1
2696
by: Chris Murphy via DotNetMonster.com | last post by:
Hi all, I'm just wondering if any one can help me with this development issue I'm having. I've created a customized treeview control to handle the particular tasks to which I'll be using it. Within...
3
4765
by: RahimAsif | last post by:
I am writing an application that requires the a portion of the main menu to be dynamic. The menu has file, panels, view files and help across the top. The view files sub menu needs to be...
0
2707
by: JamesOo | last post by:
I have the code below, but I need to make it searchable in query table, below code only allowed seach the table which in show mdb only. (i.e. have 3 table, but only can search either one only,...
0
7216
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7098
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7367
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7018
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7471
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5613
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
3187
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1528
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
407
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.