Solved

Adding Activated / Deactivate Event Handlers via IDE

Posted on 2004-03-26
7
496 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
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

 
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

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

Introduction                                                 Was the var keyword really only brought out to shorten your syntax? Or have the VB language guys got their way in C#? What type of variable is it? All will be revealed.   Also called…
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…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

744 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

9 Experts available now in Live!

Get 1:1 Help Now