Я пытаюсь реализовать объект listview в моем приложении, но по какой-то причине мой listview не отображает текст ни на одном из элементов.Элементы добавлены, и отображается маленькая иконка.
Результат, который я хотел бы (скриншот www).
Мой текущийрезультат
Ниже приведен код, который я использую для генерации списка.Представление списка добавляется в winform с использованием дизайнера.
Public Class OccurrenceControl
' Local variable
Private _occurrence As Inventor.ComponentOccurrence
Public Sub New()
' This call is required by the designer.
InitializeComponent()
' Add any initialization after the InitializeComponent() call.
' Create a new image list
Dim imageList As ImageList = New ImageList()
imageList.ImageSize = New Drawing.Size(32, 32)
imageList.Images.Add(My.Resources.MateConstraint)
imageList.Images.Add(My.Resources.AngleConstraint)
imageList.Images.Add(My.Resources.TangentConstraint)
imageList.Images.Add(My.Resources.InsertConstraint)
' Set the listview small images list
lvConstraints.SmallImageList = imageList
' Make the list scrollable
lvConstraints.Scrollable = True
' Set the listview view type
lvConstraints.View = View.List
End Sub
Public Sub ShowInfo(ByVal Occurrence As Inventor.ComponentOccurrence)
' Populate the local variable with the passed occurrence
_occurrence = Occurrence
' Clear all listed constraints
lvConstraints.Items.Clear()
' Set the grounded checkbox value
cbGrounded.Checked = Occurrence.Grounded
' Loop all constraints.
For Each oConstraint As Inventor.AssemblyConstraint In Occurrence.Constraints
' Create a new listview item
Dim oListItem As New ListViewItem
' Give the listview item a name
oListItem.Name = oConstraint.Name
' Add a image based on the constraint type.
If oConstraint.Type = Inventor.ObjectTypeEnum.kFlushConstraintObject Or Inventor.ObjectTypeEnum.kMateConstraintObject Then
oListItem.ImageIndex = 0
ElseIf oConstraint.Type = Inventor.ObjectTypeEnum.kAngleConstraintObject Then
oListItem.ImageIndex = 1
ElseIf oConstraint.Type = Inventor.ObjectTypeEnum.kTangentConstraintObject Then
oListItem.ImageIndex = 2
ElseIf oConstraint.Type = Inventor.ObjectTypeEnum.kInsertConstraintObject Then
oListItem.ImageIndex = 3
End If
' Add the new listview item to the listview
lvConstraints.Items.Add(oListItem)
Next
End Sub
End Class