Partilhar via


Visual Basic Concepts

Making Your Control Align to the Edges of Forms

When creating controls like toolbars and status bars, it's useful to be able to make the control align to one of the borders of the form it's placed on. You can give your ActiveX control this capability by setting the Alignable property of the UserControl object to True.

If the container your control is placed on supports aligned controls, it will add an Align property to the Extender object. When the user chooses an alignment, your control will automatically be aligned appropriately.

In the Resize event of your UserControl, you will have to redraw your user-drawn control or rearrange the constituent controls of your control assembly. You can use the Align property of the Extender object to determine which container edge the control instance has been aligned to.

Note   Not all containers support alignable controls. If you attempt to test the value of the Align property, make sure you use error trapping.