Other Controls and Components

201 In a multiline text box, this property determines whether scrollbars are shown on the control. The property can take any member of the ScrollBars enumeration: None the default, Horizontal , Vertical , and Both . TextAlign This property determines how text is aligned in the text box. It can take any member of the HorizontalAlignment enumeration: Center , Left , and Right .

5.1.17 The Timer Class

The Timer class represents a timer that can trigger an event at a specified interval. At each interval, a Timer object raises its Tick event. You can write code in the Tick event handler that runs regularly. The Timer will raise its Tick event only after you call its Start method. To stop the timer, call its Stop method. The interval for the Timer is set by assigning a value to its Interval property. It accepts a number representing the interval in milliseconds. The following code, which prints an incremented integer from 1 to 20 to the console, shows how to use a timer: Dim i As Integer Friend WithEvents timer1 As Timer timer1 = New Timer timer1.Interval = 1000 timer1.Start The event handler for Tick. Private Sub Timer1_Tick _ ByVal sender As System.Object, _ ByVal e As System.EventArgs _ Handles Timer1.Tick If i 20 Then i = i + 1 Console.WriteLinei Else timer1.Stop End If End Sub

5.1.18 Other Controls and Components

In addition to the controls weve discussed in some detail in the preceding sections, the .NET Framework includes a number of other controls and components for Windows application development. These include: AxHost Wraps ActiveX controls to let them be used within Windows Forms. CheckedListBox The same as the ListBox control, except that checkboxes are displayed to the left of each item. The CheckedListBox control derives from the ListBox control. ContainerControl 202 A container for other controls. The emphasis of this control is on managing the focus state of contained controls. For example, it has a method that can be called to force activation of a given contained control ActivateControl and an overridable method that is invoked when the user tabs between contained controls ProcessTabKey. The ContainerControl control provides automatic support for scrolling because it derives from ScrollableControl. When contained controls are anchored or docked, they anchor or dock to the edges of the containing control. ContextMenu Provides a method for displaying a context menu also known as a pop-up menu. Context menus are usually displayed in response to the user right-clicking the mouse. See Sect ion 5.5 later in this chapter for details. DataGrid A grid control for displaying ADO.NET data. See Chapt er 8 for examples. DomainUpDown A Windows up-down control also known as a spin button that allows the user to select from a list of text values by clicking the controls up and down arrows. See also NumericUpDown, later in this list. HScrollBar A standard Windows horizontal scrollbar. MainMenu Provides a method for displaying an applications main menu. See Sect ion 5.5 later in this chapter for details. MenuItem Represents a menu item within a menu. See Sect ion 5.5 later in this chapter for details. NotifyIcon Provides a way to put an icon into the Windows System Tray. NumericUpDown A Windows up-down control also known as a spin button that allows the user to select from a list of numeric values by clicking the controls up and down arrows. See also DomainUpDown, earlier in this list. PrintPreviewControl Displays a preview image of a document to be printed. The PrintPreviewControl is not usually used directly. It is found on the PrintPreviewDialog form discussed later in this chapter, in Sect ion 5.4 . 203 ProgressBar A standard Windows progress bar. PropertyGrid A user interface for viewing and setting the properties of any object. RichTextBox A standard Windows rich text box also known as a rich edit control. The RichTextBox control can manipulate text in Rich Text Format RTF. ScrollableControl Not used directly. The ScrollableControl control serves as the base class for controls that need to provide automatic support for scrolling. The ContainerControl control and the Panel control are both derived from ScrollableControl. Splitter Provides the user with a way to resize docked controls using the mouse. This will be discussed later in this chapter, under Sect ion 5.3 . StatusBar A standard Windows status bar. TabControl A container that provides pages to contain other controls and tabs to click to move between the pages. The pages are instances of the TabPage control, which is derived from the Panel control. ToolBar A standard Windows toolbar. TrackBar A standard Windows trackbar also known as a slider TreeView A standard Windows tree view. UserControl Not used directly. UserControl serves as the base class for developer-created container controls. See Sect ion 5.6 later in this chapter. VScrollBar A standard Windows vertical scrollbar. 204

5.2 Control Events