Summary

Team Fly 

Page 542

            LI = New ListViewItem()
            LI.Text = '' "
        Next
    Next
End Sub

The outer loop adds a new item for each publisher in the publishers table. Then it retrieves all the books under the current publisher by calling the GetChildRows method of the DataRow object that represents the current publisher. The selected titles are stored in an array of typed DataRow objects.

The first nested loop iterates through the titles and retrieves each title's entries in the titleauthor DataTable. These entries, which are pairs of title/author IDs and correspond to the authors of the current title, are stored in the TitleAuthorRows array. The last nested loop goes through these rows and retrieves the authors of the current title by calling the GetParentRows method of the current TitleAuthorRow object.

The code also keeps track of the changes in the publisher name and title, so that it can add each publisher's first title next to the publisher name, but not repeat the same publisher name until it runs into a new publisher. The same is true for titles: titles with multiple authors appear only once, but each author is added to the ListView control as a separate item. You can open the Relations1 project in the Visual Studio IDE and go through its code, which contains quite a few comments, which are not shown in Listing 18.23.

Summary

In this chapter we've shown a few practical data-driven applications. The DataGrid control is not the utlimate tool for displaying data—in fact it's not even the most appropriate control for building data-driven interfaces. Typical business applications use the same controls used to build any other type of interface.

Some of the more advanced and richer Windows controls, such as the ListView and TreeView controls are not even data-bound. However, it's fairly straightforward to populate them with data from a DataSet, as you have seen in the examples of this chapter. The DataGrid control is a very convenient tool for developers, because it allows you to quickly view the contents of a DataSet, but it's not the most suitable control for building intuitive interfaces for end users. The ListView control is ideal for displaying data. In Chapter 7 we developed a custom control that inherits from the ListView control and can also print its contents. You can combine this custom control with the techniques of this chapter to build even more functional interfaces.

You've also seen an example of a data-driven application that makes use of a middle tier component to simplify the deployment of the application. The middle tier component was implemented as part of the application, but we discussed in Chapter 14 how to deploy middle tier components as COM+ applications, web services or remotable components.

Team Fly 


Visual Basic  .NET Power Tools
Visual Basic .NET Power Tools
ISBN: 0782142427
EAN: 2147483647
Year: 2003
Pages: 178

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net