Вот данные, которые поддерживают ComboBox и ListView.
Imports System.Collections.ObjectModel
Класс Window1
Public Airports As New ObservableCollection(Of Airport)
Public Sub New()
' This call is required by the Windows Form Designer.
InitializeComponent()
'*************************
'Dummy data for testing
Dim anAirports As New Airport
anAirports.Name = "ABC"
anAirports.Category = "AA"
Airports.Add(anAirports)
anAirports = New Airport
anAirports.Name = "DEF"
anAirports.Category = "BB"
Airports.Add(anAirports)
'*************************
'Bind the airports to the list for display
lstCategories.ItemsSource = Airports
End Sub
Конечный класс
Аэропорт Публичного Класса
''' <summary>
''' Name of the Airport
''' </summary>
''' <remarks></remarks>
Private mName As String
Public Property Name() As String
Get
Return mName
End Get
Set(ByVal value As String)
mName = value
End Set
End Property
''' <summary>
''' Describes the type airport and is selected from a combobox
''' </summary>
''' <remarks></remarks>
Private mCategory As String
Public Property Category() As String
Get
Return mCategory
End Get
Set(ByVal value As String)
mCategory = value
End Set
End Property
Конечный класс
''»
'' 'Элементы, которые должны отображаться в ComboBox
«»»
«»»
Категории публичного класса
Inherits ObservableCollection(Of String)
Public Sub New()
Me.Add("AA")
Me.Add("BB")
End Sub
Конечный класс