[ Pobierz całość w formacie PDF ]
.To add to the confusion, many controls are available on both toolbars.For example,the Forms toolbar and the Control Toolbox toolbar both have a control namedListBox.However, these are two entirely different controls.In general, the ActiveXcontrols (those on the Control Toolbox toolbar) provide more flexibility.NoteThis chapter focuses exclusively on the controls that are available in the ControlToolbox toolbar, as shown in Figure 37-2.Figure 37-2: The Control Toolbox toolbar.A description of the buttons in the Control Toolbox appears in Table 37-1. 44 539671 ch37.qxd 8/28/03 10:06 AM Page 735Chapter 37 &' Using UserForm Controls in a Worksheet735Table 37-1Buttons on the Control Toolbox ToolbarButton What It DoesDesign Mode Toggles design modeProperties Displays the Properties window, where you make changes tothe control s settingsView Code Switches to the Visual Basic Editor so that you can write oredit VBA code for the selected controlCheckBox Inserts a CheckBox control (to control Boolean options)TextBox Inserts a TextBox control (allows the user to type text)CommandButton Inserts a CommandButton control (a clickable button)OptionButton Inserts an OptionButton control (to allow a user to select frommultiple options)ListBox Inserts a ListBox control (to allow the user to select an itemfrom a list)ComboBox Inserts a ComboBox control (a drop-down list)ToggleButton Inserts a ToggleButton control (to control Boolean options)SpinButton Inserts a SpinButton control (to specify a value by clicking upor down)ScrollBar Inserts a ScrollBar control (to specify a value by dragging a bar)Label Inserts a Label control (a container for text)Image Inserts an Image control (to hold an image)More Controls Displays a list of other ActiveX controls that are installed onyour systemUsing ControlsAdding ActiveX controls in a worksheet is easy.After you add a control, you canadjust its properties to modify the way that the control looks and works.Adding a controlTo add a control to a worksheet, make sure that the Control Toolbox toolbar is dis-played (and don t confuse it with the Forms toolbar).Then, click and drag the con-trol that you want to use into the worksheet to create the control.You don t need to 44 539671 ch37.qxd 8/28/03 10:06 AM Page 736Part VI &' Programming Excel with VBA736be too concerned about the exact size or position because you can modify theseproperties at any time.About design modeWhen you add a control to a worksheet, Excel goes into design mode.In this mode,you can adjust the properties of any controls on your worksheet, add or editmacros for the control, or change the control s size or position.When Excel is in design mode, you can t try out the controls.To test the controls,you must exit design mode by clicking the Exit Design Mode button on the ControlToolbox toolbar.When you re working with controls, it s not uncommon to need toswitch in and out of design mode frequently.Adjusting propertiesEvery control that you add has various properties that determine how it looks andbehaves.You can adjust these properties only when Excel is in design mode.Whenyou add a control to a worksheet, Excel enters design mode automatically.If youneed to change a control after you exit design mode, simply click the Design Modebutton on the Control Toolbox toolbar.To change the properties for a control, select the control and then click theProperties button on the Control Toolbox toolbar.Excel displays its Propertieswindow, as shown in Figure 37-3.The Properties window has two tabs.TheAlphabetic tab displays the properties in alphabetical order.The Categorized tabdisplays the properties by category.Both tabs show the same properties; only theorder is different.Figure 37-3: The Properties window lets you adjustthe properties of a control. 44 539671 ch37.qxd 8/28/03 10:06 AM Page 737Chapter 37 &' Using UserForm Controls in a Worksheet737To change a property, select it in the Properties window and then make the change.The manner in which you change a property depends on the property.Some prop-erties display a drop-down list that enables you to select from a list of options.Others (such as Font) provide a button that, when clicked, displays a dialog box.Other properties require you to type the property value.When you change a prop-erty, the change takes effect immediately.TipTo learn about a particular property, select the property in the Properties windowand press F1.Common propertiesEach control has its own unique set of properties.However, many controls shareproperties.This section describes some of the properties that are common to all ormany controls, as set forth in Table 37-2.Table 37-2Properties Shared by Multiple ControlsProperty DescriptionAutoSize If True, the control resizes itself automatically, based on thetext in its caption.BackColor The background color of the control.BackStyle The style of the background (either transparent or opaque).Caption The text that appears on the control.LinkedCell A worksheet cell that contains the current value of a control.ListFillRange A worksheet range that contains items displayed in a ListBoxor ComboBox control.Value The control s value.Leftand Top Values that determine the control s position.Widthand Height Values that determine the control s width and height.Visible If False, the control is hidden [ Pobierz całość w formacie PDF ]

  • zanotowane.pl
  • doc.pisz.pl
  • pdf.pisz.pl
  • wpserwis.htw.pl