when you double-click the control in the designer. How should you configure the control?

A Domain.com manager named Andy Booth has asked you to develop a custom control that exposes a custom event. The custom event should be of such a caliber that the event handler for the event is automatically added to the code when you double-click the control in the designer. How should you configure the control?

A Domain.com manager named Andy Booth has asked you to develop a custom control that exposes a custom event. The custom event should be of such a caliber that the event handler for the event is automatically added to the code when you double-click the control in the designer. How should you configure the control?

A.
Apply the DefaultEvent attribute the class that presents the custom control and specify the name of the event as a parameter to the attribute.

B.
Override the OnDoubleClick method on the Control class and call the AddEventHandler method of the EventDescriptor class.

C.
Override the OnDoubleClick method on the Control class and call the AddEventHandler method of the EventInfo class.

D.
Apply the DefaultEvent attribute the class that presents the custom control and specify the name of the event handler method as a parameter to the attribute.

Explanation:
The DefaultEvent attribute specifies the name of the event for which an event handler should be created, when double-clicking the control in the designer.

Incorrect Answers:
B: You should not do this. This allows you to programmatically attach each event handler to an event, discovered via reflection.
C: Doing this, will allow you to programmatically attach each event handler to an event, discovered via reflection. You then cannot use this to generate a code for the event.
D: This specifies the name of the event as a parameter.



Leave a Reply 0

Your email address will not be published. Required fields are marked *