Visual Basic: Windows Controls

UpDown Control

See Also   Example   Properties   Methods   Events

An UpDown control has a pair of arrow buttons which the user can click to increment or decrement a value, such as a scroll position or a value in an associated control, known as a buddy control.

Syntax

UpDown

Remarks

To the user, an UpDown control and its buddy control often look like a single control. The buddy control can be any control that can be linked to the UpDown control through the BuddyControl property, and usually displays data, such as a TextBox control or a CommandButton control.

Note   Lightweight windowless controls, such as the intrinsic label control, can't be used as a buddy control.

By setting the AutoBuddy property, the UpDown control automatically uses the previous control in the tab order as its buddy control. If there is no previous control in the tab order, the UpDown control will use the next control in the tab order as its buddy control. Another way to set the buddy control is with the BuddyControl property. At design time, when either the AutoBuddy property or the BuddyControl property is set, the buddy control will automatically pair up with the UpDown control by sizing and positioning next to it. The UpDown control can be positioned to the right or left of its buddy control with the Alignment property.

Note The Updown control relies on the Visual Basic implementation of extended properties like "Tab Index" and "Name." Because the VC++ resource editor does not support these properties, this control will not work with an MFC dialog app.

The Increment, Min, Max, and Wrap properties specify how the UpDown control's Value property changes when the user clicks the buttons on the control. For example, if you have values that are multiples of 10, and range from 20 to 80, you can set the Increment, Min, and Max properties to 10, 20, and 80, respectively. The Wrap property allows the Value property to increment past the Max property and start again at the Min property, or vice versa.

An UpDown control without a buddy control functions as a sort of simplified scroll bar.

Note   The UpDown control should be used in place of the Spin Button control from Visual Basic 4.0.

Distribution Note   The UpDown control is part of a group of ActiveX controls that are found in the MSCOMCT2.OCX  file. To use the UpDown control in your application, you must add the MSCOMCT2.OCX  file to the project. When distributing your application, install the MSCOMCT2.OCX  file in the user's Microsoft Windows SYSTEM directory. For more information on how to add a custom control to a project, see the Programmer's Guide.