As discussed in the In Depth section of this chapter, and in the topic "Creating List Views" earlier in the Immediate Solutions, there are four different types of views in list views: large icon view, report view (also called details view), small icon view, and list view. You can switch between these views by assigning View.LargeIcon (which equals 0), View.Details (which equals 1), View.SmallIcon (which equals 2), or View.List (which equals 3) to a list view's View property. To do this in the ListViews example on the CD-ROM, I create a combo box, this way:
With ComboBox1 .Items.Add("Large Icon View") .Items.Add("Report View") .Items.Add("Small Icon View") .Items.Add("List View") End With
Because the index of each combo box item matches the actual value of each item in the View enumeration, I can simply assign the index of the combo box's selected item to the list view's View property when the user makes a selection:
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged ListView1.View = ComboBox1.SelectedIndex End Sub
You can see the results in Figure 10.15, where I've selected large icon view in the ListViews example on the CD-ROM.