Solved

Converting string to Event type

Posted on 2006-06-14
2
410 Views
Last Modified: 2008-02-01
string temp = fileNewMenuItem_Click;
System.EventHandler temp = new System.EventHandler(temp);

How can I do this conversion....

0
Comment
Question by:prgeorge3383
2 Comments
 
LVL 11

Accepted Solution

by:
Expert1701 earned 500 total points
Comment Utility
This should work:

  {
    string temp = "fileNewMenuItem_Click";
    EventHandler handler = (EventHandler)Delegate.CreateDelegate(typeof(EventHandler), this, temp);

    handler(null, null);
  }

  void fileNewMenuItem_Click(object sender, EventArgs e)
  {
  }

if fileNewMenuItem_Click is a static method use,

  EventHandler handler = (EventHandler)Delegate.CreateDelegate(typeof(EventHandler), typeof(CLASS_NAME), temp);
0
 

Author Comment

by:prgeorge3383
Comment Utility
cool it worked great
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now