Solved

Adding Activated / Deactivate Event Handlers via IDE

Posted on 2004-03-26
7
501 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
"Emulate" TAB key when press Enter Key 3 68
Name Space error VS2015 1 35
Code works but breaks when I add one section 4 28
itextsharp with c# 3 18
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…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

763 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