Imports Infragistics.Win.UltraWinListView
Imports Infragistics.Win
...
Private Sub Populate_the_WinListView_Control_with_Items_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
' TODO: This line of code loads data into the 'NWindDataSet.Customers' table.
' You can move, or remove it, as needed.
Me.CustomersTableAdapter.Fill(Me.NWindDataSet.Customers)
' Set the control's View property to 'Tiles'
Me.UltraListView1.View = UltraListViewStyle.Tiles
' Set some properties so that SubItems (and their respective
' columns) are visible by default in the views that support
' columns, and also, make the column names and sub-item
' values not appear in tooltips by default.
Me.UltraListView1.ViewSettingsDetails.SubItemColumnsVisibleByDefault = True
Me.UltraListView1.ViewSettingsTiles.SubItemsVisibleByDefault = True
Me.UltraListView1.ItemSettings.SubItemsVisibleInToolTipByDefault = False
' Add the names of the columns that will be hidden
' to an ArrayList
Dim hiddenColumns As ArrayList = New ArrayList(4)
hiddenColumns.Add("ContactName")
hiddenColumns.Add("ContactTitle")
hiddenColumns.Add("Phone")
hiddenColumns.Add("Fax")
' Iterate the table's Columns collection and add a
' member to the WinListView control's SubItemColumns
' collection for each field in the table.
Dim dataColumn As DataColumn
For Each dataColumn In Me.NWindDataSet.Tables("Customers").Columns
' Do not add a SubItemColumn for the 'CustomerID' field
' we will assign that value to the item's Tag
If (dataColumn.ColumnName = "CustomerID") Then
ElseIf (dataColumn.ColumnName = "CompanyName") Then
' Do not add a SubItemColumn for the 'CustomerName' field
' we will represent that field with the control's MainColumn
Dim mainColumn As UltraListViewMainColumn = Me.UltraListView1.MainColumn
mainColumn.Text = "Company Name"
mainColumn.DataType = dataColumn.DataType
Else
' For all other fields, add a member to the
' SubItemColumns collection
Dim subItemColumn As UltraListViewSubItemColumn
subItemColumn = Me.UltraListView1.SubItemColumns.Add(dataColumn.ColumnName)
subItemColumn.DataType = dataColumn.DataType
End If
Next
' set the appropriate properties for the hidden columns so that
' they do not appear in the Details or Tiles view, and since it
' is not being displayed, make it appear in the tooltips.
Dim i As Integer
For i = 0 To hiddenColumns.Count - 1
Dim hiddenColumn As String = hiddenColumns(i)
Dim subItemColumn As UltraListViewSubItemColumn = Me.UltraListView1.SubItemColumns(hiddenColumn)
subItemColumn.VisibleInDetailsView = DefaultableBoolean.False
subItemColumn.VisibleInTilesView = DefaultableBoolean.False
subItemColumn.VisibleInToolTip = DefaultableBoolean.True
subItemColumn.VisiblePositionInToolTip = i
Next
' Iterate the table's Rows collection and add an item
' to the WinListView control's Items collection for each
' row in the table
For i = 0 To Me.NWindDataSet.Tables("Customers").Rows.Count - 1
Dim row As DataRow = Me.NWindDataSet.Tables("Customers").Rows(i)
' Break out the field values for this row
Dim customerID As String = row("CustomerID")
Dim companyName As String = row("CompanyName")
Dim contactName As Object = row("ContactName")
Dim contactTitle As Object = row("ContactTitle")
Dim address As Object = row("Address")
Dim city As Object = row("City")
Dim region As Object = row("Region")
Dim postalCode As Object = row("PostalCode")
Dim country As Object = row("Country")
Dim phone As Object = row("Phone")
Dim fax As Object = row("Fax")
' Add an item to the WinListView control's Items collection, using the
' value of the CustomerID field as the item's Key, and the value of the
' CompanyName field as the item's Value.
Dim item As UltraListViewItem = Me.UltraListView1.Items.Add(customerID, companyName)
' Assign the field values to the Value property of the
' corresponding UltraListViewSubItem
item.SubItems("ContactName").Value = contactName
item.SubItems("ContactTitle").Value = contactTitle
item.SubItems("Address").Value = address
item.SubItems("City").Value = city
item.SubItems("Region").Value = region
item.SubItems("PostalCode").Value = postalCode
item.SubItems("Country").Value = country
item.SubItems("Phone").Value = phone
item.SubItems("Fax").Value = fax
Next
End Sub