How to Define Default Event?

S

Stephen Barrett

We have a couple of webcontrols that we have built for our web development.
All these controls basically listen to a single event handler. The controls
are currently loaded into our toolbox for drag and drop addition.

I have noticed that on the controls from MSFT, if you double click it in
design view, it wires up the event handler in the OnInit and takes you to
code view.

I would like to add this functionality to our controls to save developer
time doing it manually by switching to "event" view on the property page of
the control and manually typing in the EventHandler property.

Can someone point me in the right direction or let me know how to do this?

TIA,
Stephen
 
A

Alessandro Zifiglio

hi Steven,
You must expose this event to the client from within your control. In the
public event handler, your custom control exposes, mark it as you would with
any property you want exposed in the propertygrid. The events go in the
action category like :

[
Category("Action"),
Description("Raised when MySomeButton click occurs.")
]
public event SomebuttoEventHandler MyButtonCommand {
add {
Events.AddHandler(EventMyButtonCommand, value);
}
remove {
Events.RemoveHandler(EventMyButtonCommand, value);
}
}
 

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

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top