Wrox Programmer Forums
|
Pro VB.NET 2002/2003 For advanced Visual Basic coders working .NET version 2002/2003. Beginning-level questions will be redirected to other forums, including Beginning VB.NET.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro VB.NET 2002/2003 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 25th, 2003, 10:24 PM
Registered User
 
Join Date: Jun 2003
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to jbrenn@friends.edu
Default AddHandler from String

How can I convert a string into a menuItem event? In other words, I'm trying to read the string out of a database or an xml file, then convert it to an eventhandler for a menuitem.

Thanks for your help,
Joey
 
Old July 4th, 2003, 07:01 AM
Registered User
 
Join Date: Jul 2003
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Are you trying to set during runtime which eventhandler is to be used?

I've tried that, but AddressOff will not accept variables. From my (basic) compiler understanding this is due to the fact that procedure (& variable) names are lost in compilation.

Mayby you can set a local variable and use the "normal" eventhandler to distinguish between the options.

Hope this helps,
Frank



 
Old July 6th, 2003, 04:18 PM
Registered User
 
Join Date: Jun 2003
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to jbrenn@friends.edu
Default

This is my problem. So the question is, now that I have the name in text (read from a database) what is the best way to invoke it? The goal is to make it the easiest for the UI developer. I want to get it down to just one line of code to add to a form or inherit from a base class which handles all the menu items.

1. I could create a delegate that calls a generic function containing a big 'Select case' statement. This would solve the problem.

2. I could create a base class that handles the normal functions, like help, about, exit, etc. This class could then be inherited and the UI programmer would be responsible to Inherit this class and provide the additional code. This would solve the problem.

3. I could use reflection and look through an assembly and invoke the appropriate methods. This would solve the problem.

4. I could create a event collection to loop through and invoke the method by creating an event. I have seen this implemented in a C# implementation.

So any ideas? I'm open to suggestions.

Thanks,
Joey





Similar Threads
Thread Thread Starter Forum Replies Last Post
Why is addhandler for linkbutton.click not working rsearing ASP.NET 2.0 Basics 7 November 12th, 2007 06:06 PM
addhandler catch 22 roog ASP.NET 1.0 and 1.1 Professional 2 February 20th, 2006 01:01 PM
Beware the AddHandler etoostr General .NET 0 November 6th, 2004 05:53 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.