Solved

Adding Activated / Deactivate Event Handlers via IDE

Posted on 2004-03-26
7
497 Views
Last Modified: 2010-05-18
I'm using VS.NET 2003 with C# as my programming language.  When I create a form, I can add most event handlers for it by going to the "Properties" window and clicking the lightning bolt.  However, certain key event handlers don't show up (including "Activated" and "Deactivate").  When I use the Class Viewer I see that the events do exist and I can override OnActivated and OnDeactivate, but I want to add an event handler for Activated / Deactivate, not override the OnActivated / OnDeactivate methods.

Do you know how to add Activated / Deactive event handlers via the IDE so that I won't have to bother hand-coding the declaration and the code to register the method as an event handler?

Thanks,
Alex
0
Comment
Question by:Egore
  • 4
  • 3
7 Comments
 
LVL 7

Accepted Solution

by:
vbwizardry earned 125 total points
ID: 10691762
Add this code to InitializeComponent in the form.
this.Activated += new System.EventHandler(this.frmTest_Activated);
this.Deactivate += new System.EventHandler(this.frmTest_Deactivated);

Also add this functions to the form class
private void frmTest_Activated(object sender, System.EventArgs e)
{
}

private void frmTest_Deactivated(object sender, System.EventArgs e)
{
}
See if it works for you.
0
 
LVL 3

Author Comment

by:Egore
ID: 10691937
That works fine (it's my current solution).  However, I was looking for a way to select the events from a list in the IDE and have them inserted in automatically like all of the events listed under the lightning bolt icon.

Thanks.
0
 
LVL 7

Expert Comment

by:vbwizardry
ID: 10691949
What version on .NET do you use. I can see both event's in my IDE.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 3

Author Comment

by:Egore
ID: 10692020
According to the help screen, it's developer environment 2003.

Are you looking in a VB.Net or a C#.Net application?  There is a huge difference in how they allow you to add events (which is actually why I posted this in the C# forum, not the .NET forum).  In VB.Net all events are listed in the code window's drop-down list (just like in VB6), but in C# you have to click the lightning bolt icon on the Properties window and only some of the possible events are listed.
0
 
LVL 7

Expert Comment

by:vbwizardry
ID: 10692063
I'm looking in C#. In C# you add events in proprty window. IE: clik on lbolt and it will show you all available events
0
 
LVL 3

Author Comment

by:Egore
ID: 10692178
Well crazily enough, you're right.  I'm working on a Pocket PC application and they're not listed in the event list, but I just tried creating a Windows application and they are listed.  Since this is such an obscure issue (only occurs when using the Compact Framework and C#) I doubt anyone will know the solution.

I'm giving you the points since you did mention the solution that I was already using, so its at least a valid way to solve the problem.

Thanks for looking into this!
0
 
LVL 7

Expert Comment

by:vbwizardry
ID: 10692204
There are many things in .NET that can be improved on ;)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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 Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

920 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

12 Experts available now in Live!

Get 1:1 Help Now