When to add a Component Class vs User Control?

后端 未结 4 1485
面向向阳花
面向向阳花 2021-02-04 00:00

I have a general idea, and there are some obvious cases, but there are also some gray areas for me - when is it best to use to extend from a component and when is it best to cre

4条回答
  •  野的像风
    2021-02-04 00:42

    I typically extend Control, or more ofter UserControl, only when I want to package some UI functionality. For Components, I think of the classic example, the Timer. It can be dropped onto the designer, configured through the Properties pane, and then accessed programmatically through the code behind. In short, I extend Component when I want to be able to manipulate some bundled-up state and behavior, an object with no UI, through the designer.

提交回复
热议问题