How to create event templates using vs.net 2003

H

harish

hello,

I am trying to write code for form activate event and for an event of an
object.

Generally, you select the object/form from the top combo box in visual
studio ide, and select the event you want to code for from the right combo
box... which would generate a template ready to write code for the event.

I am not able to do this with vs.net 2003
The two top combo boxes in the IDE show only methods and objects that are
already there in the project.. how to get auto-generated template for new
events.

thanks
'Harish
 
L

Larry Lard

harish said:
hello,

I am trying to write code for form activate event and for an event of an
object.

Generally, you select the object/form from the top combo box in visual
studio ide, and select the event you want to code for from the right combo
box... which would generate a template ready to write code for the event.

Having all the available events listed in the top right combo is a
feature of the _VB(.NET)_ IDE, as far as I am aware.
I am not able to do this with vs.net 2003
The two top combo boxes in the IDE show only methods and objects that are
already there in the project.. how to get auto-generated template for new
events.

One way to do this in the C# IDE is in the docs under the topic title
'Hooking up to Events'; I reproduce some of it here:
In the Code Editor, IntelliSense can help you hook up methods (event
handlers) to event fields. See the Events Tutorial for more conceptual
information.

When you type the += operator after an event field, IntelliSense
prompts you with an option to press the TAB key. This inserts a new
instance of a delegate that points to the method that will handle the
event.



If you press TAB, then IntelliSense automatically completes the
statement for you and displays the event handler reference as selected
text in the Code Editor. To complete the automatic event hookup,
IntelliSense prompts you to press the TAB key again, to create an empty
stub for the event handler.



Note If your new delegate (created by IntelliSense) references an
existing event handler, then IntelliSense conveys this information in
the ToolTip. You can then modify this reference, as the text is already
selected in the Code Editor. Otherwise, automatic event hook up is
complete at this point.
If you press TAB, then IntelliSense stubs out a method with the correct
signature and places the cursor in the body of your event handler.

Note Use the Navigate Back command (CTRL+-) to go back to the event
hookup statement.
Note also that the automatic naming convention used by MS for event
handlers (objectname_eventname) is disapproved of by some people.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top