The RichTextBox control is the core of a full-blown word processor. It provides all the functionality of a TextBox control; it can handle multiple typefaces, sizes, and attributes, and offers precise control over the margins of the text (see Figure … [Read more...] about RichTextBox Control
Windows Controls
Text Manipulation and Formatting Properties of RichTextBox Control
The RichTextBox control provides properties for manipulating the selected text on the control. The names of these properties start with the Selection or Selected prefix, and the most commonly used ones are shown in Table 4.5. Some of these properties … [Read more...] about Text Manipulation and Formatting Properties of RichTextBox Control
Advanced Editing Features in a RichTextBox Control
The RichTextBox control provides all the text-editing features you’d expect to find in a text-editing application, similar to the TextBox control. Among its more-advanced features, the RichTextBox control provides the AutoWordSelection property, … [Read more...] about Advanced Editing Features in a RichTextBox Control
Searching in a RichTextBox Control
To locate a string in the text of the RichTextBox control, use the Find method. The Find method is quite flexible, as it allows you to specify the type of the search, whether it will locate entire words, and so on. The simplest form of this method … [Read more...] about Searching in a RichTextBox Control
Handling URLs in the RichTextBox Document
An interesting feature of the RichTextBox control is the automatic formatting of URLs embedded in the text. To enable this feature, set the DetectURLs property to True. Then, as soon as the control determines that you’re entering a URL (usually after … [Read more...] about Handling URLs in the RichTextBox Document
The RichTextBoxPad Project – RichTextBox Control
Creating a functional — even fancy — word processor based on the RichTextBox control is unexpectedly simple. The challenge is to provide a convenient interface that lets the user select text, apply attributes and styles to it, and then set the … [Read more...] about The RichTextBoxPad Project – RichTextBox Control
ListView, TreeView, and ImageList Controls
Earlier in this chapter you learned how to use the ListBox control for displaying lists of strings and storing objects. The items of a ListBox control can be sorted, but they have no particular structure. I’m sure most of you wish that the ListBox … [Read more...] about ListView, TreeView, and ImageList Controls
Tree and List Structures of TreeView Control
The TreeView control implements a data structure known as a tree. A tree is the most appropriate structure for storing hierarchical information. The organizational chart of a company, for example, is a tree structure. Every person reports to another … [Read more...] about Tree and List Structures of TreeView Control
ImageList Control
The ImageList is a simple control that stores images used by other controls at runtime. For example, a TreeView control can use icons to identify its nodes. The simplest and quickest method of preparing these images is to create an ImageList control … [Read more...] about ImageList Control
TreeView Control
Let’s start our discussion of TreeView control with a few simple properties that you can set at design time. To experiment with the properties discussed in this section, open the TreeView Example project. The project’s main form is shown in Figure … [Read more...] about TreeView Control
Adding Nodes to a TreeView Control at Design Time
Let’s look now at the process of populating the TreeView control. Adding an initial collection of nodes to a TreeView control at design time is trivial. Locate the Nodes property in the Properties window, and you’ll see that its value is Collection. … [Read more...] about Adding Nodes to a TreeView Control at Design Time
Adding Nodes to a TreeView Control at Runtime
Adding items to the control at runtime is a bit more involved. All the nodes belong to the control's Nodes collection, which is made up of TreeNode objects. To access the Nodes collection, use the following expression, where TreeView1 is the … [Read more...] about Adding Nodes to a TreeView Control at Runtime
TreeView Example Exercise
It’s time to demonstrate the members discussed so far with an example. The project you’ll build in this section is the TreeView Example project. The project’s main form is shown in Figure 4.27. Fifure 4.27 - TreeView Example Exercise The Add … [Read more...] about TreeView Example Exercise
TreeViewDemo – The Globe Example
The Globe Example project demonstrates many of the techniques we've discussed so far. It's not the simplest example of a TreeView control, and its code is lengthy, but it will help you understand how to manipulate nodes at runtime. Because TreeView … [Read more...] about TreeViewDemo – The Globe Example
Scanning the TreeView Control
You have seen how to scan the entire tree of the TreeView control by using a For Each. . .Next loop that iterates through the Nodes collection. This technique, however, requires that you know the structure of the tree, and you must write as many … [Read more...] about Scanning the TreeView Control
ListView Control
The ListView control is similar to the ListBox control except that it can display its items in many forms, along with any number of subitems for each item. To use the ListView control in your project, place an instance of the control on a form and … [Read more...] about ListView Control
ListView Items and Subitems
As with the TreeView control, the ListView control can be populated either at design time or at runtime. To add items at design time, click the ellipsis button next to the ListItems property in the Properties window. When the ListViewItem Collection … [Read more...] about ListView Items and Subitems
ListView’s Items Collection and The SubItems Collection
The Items Collection All the items on the ListView control form a collection: the Items collection. This collection exposes the typical members of a collection that let you manipulate the control's items. These members are discussed next. Add … [Read more...] about ListView’s Items Collection and The SubItems Collection
ListView Sample Project
Let's put together the members of the ListView control to create a sample application that populates the control and enumerates its items. The sample application of this section is the ListViewDemo project. The application's form, shown in Figure … [Read more...] about ListView Sample Project
Sorting the ListView Control
The ListView control provides the Sort method, which sorts the list's items, and the Sorting property, which determines how the items will be sorted. The Sort method sorts the items in the first column alphabetically. Each item may contain any number … [Read more...] about Sorting the ListView Control