User control events

Posted by jmls on 08-Sep-2008 07:24

If I have created a user control that has an infragistics button, and then add that user control to the toolbox, how can I raise and subscribe to events that occur in the user control.

for example, the button "click" event is normally handled in the user control itself.

Do I have to manually add code to subscribe an event handler to a method in the form that is using the user control ?

I was hoping for some way of seeing "events" for the user control in the property and events tabs.

All Replies

Posted by Admin on 08-Sep-2008 08:21

When you created a user-control the button is just a member of that control and normally not exposed to the outside world (encapsulation).

The user control is self has just the events of the System.Windows.Forms.UserControl class is a inherits from that class. The ABL does not (yet?) support events in classes.

So you either have to create the method to subscribe to the event manually or try to create an inherrited control. If that inherits from the UltraButton you should be able to use the Visual Designer to create event handlers. It really depends on your use case. A user control should be used when creating a composed control - composed of a number ( >= 2) of other controls. The inherrited control let's you easily add default event handlers, modify initial properties ect. for a single control.

This thread is closed