The TextBox control is the primary mechanism for displaying and entering text. It is a small text editor that provides all the basic text-editing facilities: inserting and selecting text, scrolling if the text doesn’t fit in the control’s area, and … [Read more...] about The TextBox Control
Windows Controls
TextBox Control’s Text-Manipulation Properties
Most of the properties for manipulating text in a TextBox control are available at runtime only. This section presents a breakdown of each property. Text The most important property of the TextBox control is the Text property, which holds the … [Read more...] about TextBox Control’s Text-Manipulation Properties
TextBox Control’s Text-Selection Properties
The TextBox control provides three properties for manipulating the text selected by the user: SelectedText, SelectionStart, and SelectionLength. Users can select a range of text with a click-and-drag operation, and the selected text will appear in … [Read more...] about TextBox Control’s Text-Selection Properties
TextBox Control’s Text-Selection Methods
In addition to properties, the TextBox control exposes two methods for selecting text. You can select some text by using the Select method, whose syntax is shown next: The Select method is equivalent to setting the SelectionStart and … [Read more...] about TextBox Control’s Text-Selection Methods
The TextEditor Project – TextBox Control
The TextEditor application, shown in Figure 4.2, demonstrates most of the TextBox control's properties and methods described so far. TextEditor is a basic text editor that you can incorporate into your programs and customize for special applications. … [Read more...] about The TextEditor Project – TextBox Control
Capturing/Handling Keystrokes – TextBox Control
The TextBox control has a single unique event, the TextChanged event, which is fired every time the text on the control is changed, either because the user has typed a character or because of a paste operation. Another event that is quite common in … [Read more...] about Capturing/Handling Keystrokes – TextBox Control
Auto-complete Properties – TextBox Control
One set of interesting properties of the TextBox control are the autocomplete properties. Have you noticed how Internet Explorer prompts you with possible matches as soon as you start typing an address or your username in a text box (or in the … [Read more...] about Auto-complete Properties – TextBox Control
ListBox and CheckedListBox Controls
The ListBox, CheckedListBox, and ComboBox controls present lists of choices, from which the user can select one or more. The ListBox control occupies a user-specified amount of space on the form and is populated with a list of items. If the list of … [Read more...] about ListBox and CheckedListBox Controls
Manipulating ListBox Control’s Item Collection
To manipulate a ListBox control from within your application, you should be able to do the following: Add items to the listRemove items from the listAccess individual items in the list The items in the list are represented by the Items … [Read more...] about Manipulating ListBox Control’s Item Collection
Selecting Items from a ListBox Control
The ListBox control allows the user to select either one or multiple items, depending on the setting of the SelectionMode property. In a single-selection ListBox control, you can retrieve the selected item by using the SelectedItem property, and its … [Read more...] about Selecting Items from a ListBox Control
Adding and Removing Items from a ListBox Control
This Adding and Removing Item from a ListBox control example (shown in Figure 4.4) demonstrates the basic operations of the ListBox control. The two ListBox controls on the form operate slightly differently. The first has the default configuration: … [Read more...] about Adding and Removing Items from a ListBox Control
Searching the ListBox Control
Two of the most useful methods of the ListBox control are the FindString and FindStringExact methods, which allow you to quickly locate any item in the list. The FindString method locates a string that partially matches the one you’re searching for; … [Read more...] about Searching the ListBox Control
ComboBox Control
The ComboBox control is similar to the ListBox control in the sense that it contains multiple items and the user may select one, but it typically occupies less space onscreen. The ComboBox is practically an expandable ListBox control, which can grow … [Read more...] about ComboBox Control
Adding Items to a ComboBox at Runtime
Although the ComboBox control allows users to enter text in the control’s edit box, it doesn’t provide a simple mechanism for adding new items at runtime. Let’s say you provide a ComboBox with city names. Users can type the first few characters and … [Read more...] about Adding Items to a ComboBox at Runtime
ScrollBar and TrackBar Controls
The ScrollBar and TrackBar controls let the user specify a magnitude by scrolling a selector between its minimum and maximum values. In some situations, the user doesn’t know in advance the exact value of the quantity to specify (in which case, a … [Read more...] about ScrollBar and TrackBar Controls
Common Dialog Controls
A rather tedious, but quite common, task in nearly every application is to prompt the user for filenames, font names and sizes, or colors to be used by the application. Designing your own dialog boxes for these purposes would be a hassle, not to … [Read more...] about Common Dialog Controls
ColorDialog Control
The Color dialog box, shown in Figure 4.11, is one of the simplest dialog boxes. Its Color property returns the color selected by the user or sets the initially selected color when the user opens the dialog box. The following statements set the … [Read more...] about ColorDialog Control
FontDialog Control
The Font dialog box, shown in Figure 4.12, lets the user review and select a font and then set its size and style. Optionally, users can also select the font’s color and even apply the current settings to the selected text on a control of the form … [Read more...] about FontDialog Control
OpenDialog and SaveDialog Controls
Open and Save As, the two most widely used common dialog boxes (see Figure 4.13), are implemented by the OpenFileDialog and SaveFileDialog controls. Nearly every application prompts users for filenames, and the .NET Framework provides two controls … [Read more...] about OpenDialog and SaveDialog Controls
FolderBrowserDialog Control
Sometimes we need to prompt users for a folder, rather than a filename. An application that processes files in batch mode shouldn't force users to select the files to be processed. Instead, it should allow users to select a folder and process all … [Read more...] about FolderBrowserDialog Control