Event handler code creater for C#

G

Guest

In the Visual Studio VB user interface when I want to create an event handler
for a control, I go to the code view for the form and in a combo box at the
top left I pick the control. All the events for the control are in another
combo box on the right. When I click the event, my handler is set up.

In C# this does not appear to be the case. I have been going to the form
designer, finding my way to the control's section, and adding something like:
this: tb1.Enter += new System.EventHandler(this.t1_Enter);

Then I go to the code view and write out the handler sub (hoping I know the
proper arguments for the control’s event of interest).

Is there an easier way to do this with the C# developer UI?
 
P

Peter Duniho

mr said:
In the Visual Studio VB user interface when I want to create an event handler
for a control, I go to the code view for the form and in a combo box at the
top left I pick the control. All the events for the control are in another
combo box on the right. When I click the event, my handler is set up.

In C# this does not appear to be the case. I have been going to the form
designer, finding my way to the control's section, and adding something like:
this: tb1.Enter += new System.EventHandler(this.t1_Enter);

Then I go to the code view and write out the handler sub (hoping I know the
proper arguments for the control’s event of interest).

Is there an easier way to do this with the C# developer UI?

In the Designer, click on the "lightning bolt" icon in the Properties
window, so that you are looking at events rather than properties. Find
the event you want to handle, double-click in the empty box next to the
event, and a stub event-handler will be inserted into the containing
form class and subscribed to the event.

You can then modify the stub as necessary to implement your specific
behavior.

Pete
 

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