|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Dynamic controls, menuitems, windowlistloaded 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 YYZ wrote:
Show quoteHide quote > In my program, a user can open up many different "Loans" -- each one is Create your own class derived from MenuItem, then you can> 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. 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 > 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 Ishould 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
Show quote
Hide quote
"YYZ" <matt.da***@gmail.com> schrieb Write a class inheriting from MenuItem and add a property referencing the> 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. 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 > Write a class inheriting from MenuItem and add a property referencing the Even better -- no need to enumerate the controls collection looking for> 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. Loan objects. Thanks Armin and Larry. Matt > Write a class inheriting from MenuItem and add a property referencing the Okay, I think I'm missing something. When adding a menuitem to a menu,> 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. 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 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
Search Arraylist in Arraylist.
Advice needed on programming style PropertyBag in VB.NET? PostMessage and Combobox Question about Control Collection in VB.net Allowing access to controls from another thread accessing blob fileds from oracle Cast from string "" to type 'Date' is not valid Accessing controls from another thread project source design question |
|||||||||||||||||||||||