开发者

What is the standard approach for event handling in case of Visual Inheritance?

We know that when a Form is visually inherited, all of its controls are locked in design time. This problem requires that we place event handlers in the base form. Now what should I do if I want to place base-control event handlers in开发者_如何学JAVA the derived Form?

Since the controls are locked, approach of double clicking on the control to add an event-handler should not work.

What is the industry-standard approach for event handling in case of Visual Inheritance?


The designer honors the access modifiers on the base class members. You must change the Modifiers property of the base form's control from Private to Protected. Recompile. Now the inherited form has access to the control, you'll have no trouble overriding properties and assigning an event handler from the designer.


You handle the event on the base Form and use it to call a virtual method. The derived Form overrides that method.


Another method is to add an event in the user control (instead of a virtual method) and then fire it when the internal event is fired.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜