Imports Infragistics.Win
Imports Infragistics.Win.UltraWinListView
' Get a reference to the 'Customers', 'Employees', and
' 'Orders' tables from the Northwind database
Dim dataSet As DataSet = New DataSet()
Me.customersAdapter.Fill(dataSet)
Me.employeesAdapter.Fill(dataSet)
Me.ordersAdapter.Fill(dataSet)
Me.shippersAdapter.Fill(dataSet)
Dim customersTable As DataTable = dataSet.Tables("Customers")
Dim employeesTable As DataTable = dataSet.Tables("Employees")
Dim ordersTable As DataTable = dataSet.Tables("Orders")
Dim shippersTable As DataTable = dataSet.Tables("Shippers")
' Set the UltraListView's View property to 'Details'
Me.ultraListView1.View = UltraListViewStyle.Details
' Set the UltraListView's AutoKeyboardSearch property to true,
' so the end user can perform alpha-numeric searches
Me.ultraListView1.AutoKeyboardSearch = True
' Allow extended selection for items
Me.ultraListView1.ItemSettings.SelectionType = SelectionType.Extended
' Enable HotTracking
Me.ultraListView1.ItemSettings.HotTracking = true
' Show selected appearance colors when the control does not have focus
Me.ultraListView1.ItemSettings.HideSelection = false
' Allow extended selection for items
Me.ultraListView1.ItemSettings.SelectionType = SelectionType.Extended
' Disable editing for the UltraListView.
Me.ultraListView1.ItemSettings.AllowEdit = DefaultableBoolean.False
' Display checkboxes next to the items
Me.ultraListView1.ViewSettingsDetails.CheckBoxStyle = CheckBoxStyle.CheckBox
Me.ultraListView1.ViewSettingsList.CheckBoxStyle = CheckBoxStyle.CheckBox
' Adjust the ImageSize property so that images are not displayed
' for the list styles
Me.ultraListView1.ViewSettingsDetails.ImageSize = Size.Empty
Me.ultraListView1.ViewSettingsList.ImageSize = Size.Empty
' Set the FullRowSelect property to true for Details view
Me.ultraListView1.ViewSettingsDetails.FullRowSelect = True
' Clear the Items, Groups, and SubItemColumns collections
Me.ultraListView1.Items.Clear()
Me.ultraListView1.Groups.Clear()
Me.ultraListView1.SubItemColumns.Clear()
' Populate the Groups collection from the 'Customers' table
Dim dataRow As DataRow
For Each dataRow In customersTable.Rows
' Add an UltraListViewGroup to represent this customer, using
' the value of the 'CustomerID' field for the group's Key.
Dim group As UltraListViewGroup = Me.ultraListView1.Groups.Add(CType(dataRow("CustomerID"), String))
' Assign the value of the 'CompanyName' field to the group's Text property.
group.Text = CType(dataRow("CompanyName"), String)
Next
' Set ShowGroups to true so that groups are shown
Me.ultraListView1.ShowGroups = True
' Create a ValueList, which we will populate with the contents of
' the 'Employees' table. Use the value of the 'EmployeeID' field
' for the DataValue, and the employee's name for the DisplayText.
' Also, store a reference to the underlying DataRow in the
' ValueListItem's Tag property.
Dim employeesValueList As ValueList = New ValueList()
For Each dataRow In employeesTable.Rows
Dim employeeName As String = String.Format("{0} {1}", dataRow("FirstName"), dataRow("LastName"))
Dim valueListItem As ValueListItem = employeesValueList.ValueListItems.Add(dataRow("EmployeeID"), employeeName)
valueListItem.Tag = dataRow
Next
' Create a ValueList, which we will populate with the contents of
' the 'Shippers' table. Use the value of the 'ShipperID' field
' for the DataValue, and the shipper's name for the DisplayText.
' Also, store a reference to the underlying DataRow in the
' ValueListItem's Tag property.
Dim shippersValueList As ValueList = New ValueList()
For Each dataRow In shippersTable.Rows
Dim shipperName As String = CType(dataRow("CompanyName"), String)
Dim shipperID As Int32 = CType(dataRow("ShipperID"), Int32)
Dim valueListItem As ValueListItem = shippersValueList.ValueListItems.Add(shipperID, shipperName)
valueListItem.Tag = dataRow
' Create an Appearance for this shipper, and add it to the
' UltraListView's Appearances collection.
Dim appearance As Infragistics.Win.Appearance = Me.ultraListView1.Appearances.Add(shipperName)
Select Case shipperID
Case 1
appearance.ForeColor = Color.Red
Case 2
appearance.ForeColor = Color.Green
Case 3
appearance.ForeColor = Color.Blue
End Select
Next
' Populate the SubItemColumns collection from the Columns in the 'Orders' table
Me.PopulateSubItemColumnsCollection(ordersTable, employeesValueList, shippersValueList)
' Populate the Items collection from the Rows in the 'Orders' table
Me.PopulateItemsCollection(ordersTable)