What follows is a brief survey of the standard Windows Forms 2.0 components, listed in alphabetical order. BackgroundWorkerSee Chapter 18: Multithreaded User Interfaces. BindingNavigatorSee Chapter 16: Data Binding Basics and Chapter 17: Applied Data Binding. BindingSourceSee Chapter 16 and Chapter 17. ColorDialogSee Chapter 3: Dialogs. ErrorProviderSee Chapter 3. FolderBrowserDialogSee Chapter 3. FontDialogSee Chapter 3. HelpProviderSee Chapter 3. ImageListControls like TreeView and ListView contain tree nodes and list-view items whose images come from an ImageList component. ImageList manages a collection of images of the same size, color depth, and transparency color (as determined by the Size, ColorDepth, and TransparencyColor properties). The images themselves are stored in the Images collection and can contain any number of Image objects. You can edit the Images collection directly using the Images Collection Editor, as shown in Figure D.1. Figure D.1. Images Collection Editor
To use ImageList after the images have been populated in the editor, you pull them by index from the Images collection property: int imageIndex = -1; void timer_Tick(object sender, EventArgs e) { ++this.imageIndex; if( this.imageIndex == 4 ) this.imageIndex = 0; this.BackgroundImage = this.imageList.Images[this.imageIndex]; } What's nice about this code is that all the related images come from a single place. However, the ImageList component has some limitations:
NotifyIconSee Chapter 2: Forms. OpenFileDialogSee Chapter 3. PageSetupDialogSee Chapter 8: Printing. PrintDialogSee Chapter 8. PrintDocumentSee Chapter 8. PrintPreviewDialogSee Chapter 8. SaveFileDialogSee Chapter 3. SoundPlayerSoundPlayer is an enigma: Located in System.Media, SoundPlayer is a class that cannot be added to the Toolbox and, consequently, can't be dropped onto a form in VS05 at design time. However, it is a very useful class that happens to make it easy to play sound files:[2]
using System.Media; ... void soundPlayerButton_Click(object sender, EventArgs e) { SoundPlayer soundPlayer = new SoundPlayer(@"C:\WINDOWS\Media\tada.wav"); soundPlayer.Load(); soundPlayer.Play(); } SoundPlayer also provides support for loading sound files from streams and URLs both synchronously and asynchronously, and for looping playback. Additionally, System.Media offers shortcuts for playing common system sounds using the SystemSounds class: System.Media.SystemSounds.Exclamation.Play(); System sounds include Asterisk, Beep, Exclamation, Hand, and Question. TimerSee Chapter 18. Tool TipSee Chapter 3. |