Peter -

> 1) How do I create a control which has a fixed size in the 
> form design view in VS.  I tried
> overriding OnResize but didn't like the effect - is there a 
> better way?

If you are talking about one derived from Control, you would create a custom designer 
for your control.  Something like the following:

<Code snippet = VB.NET>

 <Designer(GetType(UnsizeableControlDesigner))> _
Public Class UnsizeableControl
        Inherits Control

        Public Class UnsizeableControlDesigner
          Inherits ControlDesigner
                Public Overrides ReadOnly Property SelectionRules() As SelectionRules
                    Get
                        Return SelectionRules.Moveable Or SelectionRules.Visible
                    End Get
                End Property
        End Class

End Class

</Code Snippet>

UserControl should be similar
 
> 2) ControlStyles - FixedHeight, FixedWidth - what do these 
> actually do?

These prevent the control from being resized.  I am guessing that you can't get them 
to work?

> 3) By what mechanism is a UserControl automatically placed in 
> the toolbar in design view in VS?

Magic.  Plain and simple.  The UserControl designer adds the item in question when 
it's shown.  It uses IToolboxService.

> 
> 4) By what mechanism are the Properties in the Properties 
> window in design view in VS created?
> Obviously some are properties of the actual Control but where 
> does 'Locked' get introduced?

Most properties are discerned from the selected object.  The designer, however, has a 
method called PrefilterProperties.  This allows you to add other properties, should 
you desire.  The locked property actually sets a SelectionRule in the designer.

> 5) Are there any good reasons why I should derive from 
> UserControl rather than Control?  (When
> there doesn't seem to be anything that I need in UserControl.)

UserControl should be used for aggregating other controls.  Otherwise, use Control.

> 
> Links to any good articles on this area would be appreciated.
 
Any article by Shawn Burke on MSDN.

Hope this helps.

Jacob A. Grass
Microsoft .NET MVP
Check out http://Windowsforms.net

You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

Reply via email to