列表视图项目文本未显示

Listview item text is not showing

我正在尝试在我的应用程序中实现 listview 对象,但是由于某种原因,我的 listview 没有在任何项目上显示文本。项目已添加,并显示小图标。

我想要的结果(截图www)。

我目前的成绩

下面是我用来生成列表视图的代码。使用设计器在winform上添加了listview。

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

您没有在任何地方设置 ListViewItemText,因此没有显示文本也就不足为奇了。