Solved

Adding Activated / Deactivate Event Handlers via IDE

Posted on 2004-03-26
7
498 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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-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!
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

810 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