ScrollToControl Method

Applies to:  SubForm Control
See also:  , Method and Function Index

Scrolls a SubForm, so that a particular control on the child form is visible.

Syntax:

object.ScrollTo(ctl As Object)

The ScrollTo syntax has these parts:

Part Description
object The name of an object in the Applies to list.
x The new position for the horizontal scroll bar.
y The new position for the vertical scroll bar.

Remarks:

The ScrollToControl method is only available if the SubForm's View property is vwSingleForm.

If the specified control is already completely visible, then ScrollToControl will have no effect.

If the specified control is partially visible, or is completely outside the visible region of the child form, then the form will be scrolled by the amount needed to bring the control into view.  If the control is contained on another control, such as a Frame or PictureBox, and if the container control will fit entirely within the visible area of the child form, then an attempt will be made to scroll the entire container control into view.

Sometimes, one will want to bring two controls into view - for example, a TextBox and a Label.  In these instances, ScrollToControl can be called twice:  Once to scroll the Label into view, and again to scroll the TextBox into view.

ScrollToControl can only be used to scroll a windowless control, such as a Label, into view, if the control's container is the child form itself.  

Example:

SubForm - Single Form View


Home

Copyright and Disclaimer