Download presentation
Presentation is loading. Please wait.
Published byJoleen Ross Modified over 9 years ago
1
CIS 338: ListView Control Dr. Ralph D. Westfall May, 2011
2
ListView Control used in Windows Explorer to view files try File>Open>Browse in IE can display data in variety of ways large or small icons displayed horizontally single or multiple-column lists multiple-column lists can be sorted (only by first columns, ascending or descending)
3
ListView Startup Code Private clmX as ColumnHeader Private itmX As ListViewItem Private Sub [formname]_Load( … etc. 'creating column headers (captions) 1st 'Optional: add ImageLists from ToolBox 'Add icons to ImageList's Images property ListView1.LargeImageList = ImageList1 ListView1.SmallImageList = ImageList2
4
ListView Headers clmX = ListView1.Columns.Add _ ("[ ]", 90, HorizontalAlignment.Center) clmX = ListView1.Columns.Add _ ("[ ]", 100, HorizontalAlignment.Center) 'repeat code for each additional header ListView1.View = View.Details 'show columns over outputs
5
ListView Row Data 'loading row of list items itmX = ListView1.Items.Add("[ ]") itmX.SubItems.Add("[ ]") itmX.SubItems.Add("[ ]" itmX.ImageIndex = (#) 'Integer ‘Can repeat for additional SubItems. ‘Can put above lines in a loop in a Sub, 'to load from an array, file or database, 'or just use loop indexes to load a demo. ‘See Notes.
6
ListView View Mode 'can set/change View property in code ListView1.View = View.Details 'table ListView1.Show() 'see array data example in Notes ListView.Clear() 'removes items, but columns stay there
7
Microsoft ListView Tutorial (more work than it's worth?) copy and paste documentation example code into a form with just a button, and then modify it as necessarydocumentation example download images below into project's \bin subdirectory image files for use with sample code image files see notes below to set code paths
8
Other ListView Tutorials Listview«GUI«VB.NET Tutorial Filling Listview with data retrieved from database
9
ListView Reversible Sorting Private Sub ListView1_ColumnClick( …notes Static intCounter As Integer 'persists If intCounter Mod 2 = 1 Then 'odd count ListView1.Sorting = SortOrder.Ascending Else 'even count ListView1.Sorting = SortOrder.Descending End If intCounter += 1 End Sub'notes: another approach ' do NOT set a Sorting value in Properties of ListView control if you use code for sorting
10
ListView Control Sorting in VB 6, it was easy to sort by columns less easy in.NET to sort just 1 st column sorting on other columns is even harder sorting on other columns my opinion is that Microsoft really should provide this as a standard feature rather than requiring additional coding
11
Getting Data into ListView Transport.zipTransport.zip code shows different ways of getting data for a ListView demonstrates use of data coming from a data tier in one of the three ways: from class objects in an array from parallel arrays from concatenated strings
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.