Chapter 16: Grid, Tree, and List Controls

Chapter 16
Grid, Tree, and List Controls
  • Using the DataGrid Control
  • Displaying Hierarchical Information in a TreeView Control
  • Using the ListView Control

If you look at an average Microsoft Windows application, you’ll notice that it uses not only stock controls such as buttons and text boxes, but also much more sophisticated controls. This chapter introduces you to three commonly used rich controls and describes how to effectively use these controls in your applications. Along the way, you’ll see how easy it is to program controls with Microsoft Visual C# .NET.

Two of the controls we’ll look at in this chapter—the TreeView control and the ListView control—are common controls, meaning that they ship with all versions of Windows and are available to any programming language, not only to Microsoft .NET Framework applications. Given that at one time or another most of the data in applications is presented either in list view or in a hierarchical tree view, you’ll probably find yourself using these controls often in your applications.

Although it isn’t a common control, the DataGrid control is bound to appear often in your Visual C# applications too. When listing data in read-only form isn’t sufficient and real data editing is needed, this control will be your choice. The DataGrid control enables you to make various types of data available for editing, supports extensive style options, and (last, but not least) is easily put to use thanks to the Visual C# .NET Forms Designer. We’ll look first at how to use the DataGrid control and then at the TreeView and ListView controls.

Part III: Programming Windows Forms