如何在 TextBox / ComboBox 中添加 ListView 的值? VB6

How do I add the values ​of a ListView in a TextBox / ComboBox? VB6

我有这个界面:

数据输入:

它们加载在 ListView:

我想要的是,当双击从列表中加载的项目时,它会出现加载时的值。也就是说,我双击列表项,它必须加载添加到 ListviewComboBox, TextBox, CheckBox 的值。这样一来,如果用户错误地加载了一段数据,则可以通过双击对其进行编辑。

我考虑过这个,但没有用:

Private Sub List_Contactos_DblClick()

Dim i As Integer
Dim IntPrincipal As Integer
Dim IntVinculo As Integer
Dim IntTipo As Integer

If MebPreFijo.Text = "" And txttel.Text = "" Then
        'For i = 1 To List_Contactos.ListItems.Count

        'CmbTipoTel
        If List_Contactos.ListItems(i).SubItems(1) = "Fijo" Then
            IntTipo = 1
        Else
            IntTipo = 2
        End If
        CmbTipoTel.Text = List_Contactos.ListItems(i).SubItems(1)

        'MebPreFijo
        MebPreFijo.Text = List_Contactos.ListItems(i).SubItems(2)

        'txttel
        txttel.Text = List_Contactos.ListItems(i).SubItems(3)

        'CheckPrincipal
        If List_Contactos.ListItems(i).SubItems(4) = "SI" Then
            IntPrincipal = 1
        Else
            IntPrincipal = 0
        End If
        ChPrincipal.value = IntPrincipal

        'ComboTipoVinculo
        If List_Contactos.ListItems(i).SubItems(5) = "" Then
            IntVinculo = 0
        Else
            Rs.Open "select tv_id from dbo.Tipo_Vinculo where tv_descripcion='" & List_Contactos.ListItems(i).SubItems(5) & "'", Cn, adOpenKeyset, adLockReadOnly
            IntVinculo = Rs!TV_Id
            Rs.Close
        End If
        ChVinculo.value = IntVinculo

        'Limpiar ese item
        List_Contactos.ListItems.Remove List_Contactos.SelectedItem.Index

    'Next i

    Else
    MsgBox "Tiene datos que se pueden perder. Por favor, presione añadir."

End If

End Sub

建议?因为当我按下该项目时,我看到下一个错误:

Index out of bounds Run-time error "35600"

下标 i 不会引用列表视图中的选定项。请尝试 SelectedItem

例如:

If List_Contactos.SelectedItem.SubItems(1) = "Fijo" Then