logo       

Re: User v Custom Controls: msg#00407

windows.devel.dotnet.winforms

Subject: Re: User v Custom Controls

You don't lose anything, but it's possible that you'll gain things you
don't want. If you plan to paint the entire surface of the control
yourself in your custom control's OnPaint method, then the design time
support won't be useful. (Indeed it will be confusing - it'll just show
a blank grey area, because the Forms Designer doesn't call the OnPaint
method for the control being edited at design time.)

You might not want scrollability or the ContainerControl features. (And
just to clarify, you don't need to derive from ContainerControl in order
to support containment. ContainerControl is mainly about focus
handling. Deriving from it can subtly change the behaviour of both
focus handling and validation. The ability to act as a container of
other controls comes from Control, not ContainerControl.) If you don't
need these things, then you're paying for stuff you're not using, which
may increase your program's working set unnecessarily.


--
Ian Griffiths - DevelopMentor
http://www.interact-sw.co.uk/iangblog/

> -----Original Message-----
> From: Craig Larsen
>
> So what do you lose by using a user control instead of a custom
control
> ?
>
> Craig Larsen
> larsenc@xxxxxxx
>
>
> -----Original Message-----
> From: Griffiths, Ian [mailto:igriffiths@xxxxxxxxxxx]
>
> Richard Heintze schrieb:
> > > How do I decide between user and custom controls?
>
> Fabian Schmied replied:
> > User controls are derived from UserControl and thus inherit the
> > infrastructure to contain other controls
>
> But UserControl inherits *that* infrastructure from Control... So
this
> is doesn't really help you in deciding between a custom control and a
> user control - custom control can contain other controls too.



<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise