Other Controls and Components
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 Sub5.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. 2045.2 Control Events
Parts
» VB.NET - (O'Reilly) Programming Visual Basic NET
» What Is the Microsoft .NET Framework?
» hello, world An Example Visual Basic .NET Program
» Hello, Windows An Example Visual Basic .NET Program
» Hello, Browser An Example Visual Basic .NET Program
» Source Files Identifiers The Visual Basic .NET Language
» Numeric Literals String Literals Character Literals
» Date Literals Boolean Literals Nothing Summary of Literal Formats
» Custom Types Collections Types
» The Namespace Statement The Imports Statement
» Symbolic Constants Scope The Visual Basic .NET Language
» Access Modifiers Assignment The Visual Basic .NET Language
» Unary Operators Arithmetic Operators
» Relational Operators Operators and Expressions
» String-Concatenation Operators Bitwise Operators
» Logical Operators Operator Precedence
» Call Exit Branching Statements
» Goto If RaiseEvent Branching Statements
» Return Select Case Branching Statements
» For Each Iteration Statements
» Object Instantiation and New Constructors
» Handling Events Inheritance Classes
» Passing arrays as parameters
» Variable-length parameter lists Main method
» Implementing interface methods Overriding inherited methods
» Overloading Overloading inherited methods
» The MyBase Keyword Nested Classes Destructors
» Interfaces The Visual Basic .NET Language
» Enumerations The Visual Basic .NET Language
» Exceptions The Visual Basic .NET Language
» Delegates The Visual Basic .NET Language
» Using Events and Delegates Together
» Creating Custom Attributes Attributes
» Standard Modules Conditional Compilation
» Summary The Visual Basic .NET Language
» Common Language Infrastructure CLI and Common Language Runtime CLR
» Global Assembly Cache GAC Comparison of Assemblies, Modules, and Namespaces
» Application Domains Common Language Specification CLS
» Intermediate Language IL and Just-In-Time JIT Compilation Metadata
» Finalize Memory Management and Garbage Collection
» Dispose Memory Management and Garbage Collection
» A Brief Tour of the .NET Framework Namespaces
» Configuration File Format Configuration
» Configuration Section Groups The appSettings Section
» Adding event handlers Creating a Form in Code
» Handling Form Events Windows Forms I: Developing Desktop Applications
» Relationships Between Forms Windows Forms I: Developing Desktop Applications
» Merging Menus MDI Applications
» Detecting MDI Child Window Activation
» Component Attributes Windows Forms I: Developing Desktop Applications
» The Graphics Class 2-D Graphics Programming with GDI+
» The Pen Class 2-D Graphics Programming with GDI+
» The Brush Class 2-D Graphics Programming with GDI+
» System colors The Color Structure
» Alpha Blending 2-D Graphics Programming with GDI+
» Antialiasing 2-D Graphics Programming with GDI+
» The PrintPageEventArgs Class Printing
» The OnBeginPrint and OnEndPrint Methods Choosing a Printer
» The PageSettings Class Printing
» The PrinterSettings Class Printing
» Page Setup Dialog Box Print Preview
» Summary Windows Forms I: Developing Desktop Applications
» The Button Class The CheckBox Class The ComboBox Class
» The DateTimePicker Class The GroupBox Class The ImageList Class
» The Label Class The LinkLabel Class
» The ListBox Class Common Controls and Components
» The ListBox.ObjectCollection Class
» The ListView Class Common Controls and Components
» The MonthCalendar Class Common Controls and Components
» The Panel Class The PictureBox Class
» The RadioButton Class Common Controls and Components
» The TextBox Class The Timer Class
» Other Controls and Components
» Control Events Windows Forms II: Controls, Common Dialog Boxes, and Menus
» The Anchor Property Form and Control Layout
» Controlling dock order The Dock Property
» The Splitter control The Dock Property
» ColorDialog FontDialog OpenFileDialog Common Dialog Boxes
» PageSetupDialog PrintDialog PrintPreviewDialog SaveFileDialog
» Adding Menus in the Visual Studio .NET Windows Forms Designer
» Programmatically Creating Menus Menus
» Building Controls from Other Controls
» Building Controls That Draw Themselves Building Nonrectangular Controls
» Summary Windows Forms II: Controls, Common Dialog Boxes, and Menus
» Setting control properties using attributes Adding event handlers
» AutoEventWireup Handling Page Events
» The Button control Web Controls
» The CheckBox control The DropDownList control
» The Image control The Label control
» The ListBox control Web Controls
» The RadioButton control Web Controls
» The Table control Web Controls
» The TextBox control Web Controls
» Other web controls Web Controls
» HTML Controls Handling Control Events
» Programmatically Instantiating Controls More About Server Controls
» More About Validation-Control Tag Attributes
» Using Validation-Control Properties Providing a Summary View of Validation Failures
» Performing Custom Validation Adding Validation
» Using Directives to Modify Web Page Compilation
» The Server Object ASP.NET Objects: Interacting with the Framework
» The Application Object The Session Object The Cache Object The Request Object
» The Response Object ASP.NET Objects: Interacting with the Framework
» Discovering Browser Capabilities ASP.NET and Web Forms: Developing Browser-Based Applications
» The Session Object Maintaining State
» The Application Object Maintaining State
» Session and Application Startup and Shutdown global.asax Compiles to a Class
» Adding Global Objects Application-Level Code and global.asax
» ASP.NET authorization Authorization
» Windows NTFS authorization Code-access authorization
» IUSR_ComputerName Impersonation Accessing Network Resources
» User Controls Designing Custom Controls
» Creating a custom server control using Visual Studio .NET
» Creating a custom server control in code Using a custom server control in Visual Studio .NET
» Summary ASP.NET and Web Forms: Developing Browser-Based Applications
» The WebService Attribute The WebMethod Attribute
» Testing a Web Service with a Browser
» Consuming a Web Service in Visual Studio .NET
» Consuming a Web Service in Notepad
» Synchronous Versus Asynchronous Calls
» Web-Service Descriptions Web-Service Discovery
» Limitations of Web Services Summary
» A Brief History of Universal Data Access Managed Providers
» Connecting to a SQL Server Database
» Connecting to an OLE DB Data Source
» The DataSet Class Finding Tables
» Finding Column Values Finding Column Definitions Changing, Adding, and Deleting Rows
» Writing Updates Back to the Data Source
» Relations Between DataTables in a DataSet
» The DataSets XML Capabilities
» Binding a DataSet to a Windows Forms DataGrid
» Binding a DataSet to a Web Forms DataGrid
» Typed DataSets ADO.NET: Developing Database Applications
» Reading Data Using a DataReader
Show more