• DİKKAT

    DOSYA İndirmek/Yüklemek için ÜCRETLİ ALTIN ÜYELİK Gereklidir!
    Altın Üyelik Hakkında Bilgi

Soru Listview selecteditem sorun

  • Konbuyu başlatan Konbuyu başlatan FERAZ
  • Başlangıç tarihi Başlangıç tarihi
Deneyiniz.

Kod:
Private Sub CommandButton1_Click()
    If Not Me.ListView1.SelectedItem Is Nothing Then
        MsgBox Me.ListView1.SelectedItem.Index
    End If
End Sub

Private Sub UserForm_Activate()
    Dim lstv As ListItem
    
    With Me.ListView1.ColumnHeaders
        .Clear
        .Add , , "Baslik1"
        .Add , , "Baslik2"
        .Add , , "Baslik3"
    End With
    
    With Me.ListView1
        .ListItems.Clear
        .View = lvwReport
        .FullRowSelect = True
        
     For i = 2 To 15
      Set lstv = .ListItems.Add(, , Cells(i, 1))
                  lstv.SubItems(1) = Cells(i, 2)
                  lstv.SubItems(2) = Cells(i, 3)
    Next i
    
    End With
    
    Set ListView1.SelectedItem = Nothing
    Set lstv = Nothing
End Sub
 
Elinize sağlık @Korhan Ayhan hocam.
Kodunuza alttaki kırmızı yeride ekleyince süper oldu.


Rich (BB code):
Private Sub CommandButton1_Click()
    If Not Me.ListView1.SelectedItem Is Nothing Then
        MsgBox Me.ListView1.SelectedItem.Index
    End If
   Set ListView1.SelectedItem = Nothing
End Sub


Private Sub UserForm_Initialize()
   Dim lstv As ListItem
    
    With Me.ListView1.ColumnHeaders
        .Clear
        .Add , , "Baslik1"
        .Add , , "Baslik2"
        .Add , , "Baslik3"
    End With
    
    With Me.ListView1
        .ListItems.Clear
        .View = lvwReport
        .FullRowSelect = True
        
     For i = 2 To 15
      Set lstv = .ListItems.Add(, , Cells(i, 1))
                  lstv.SubItems(1) = Cells(i, 2)
                  lstv.SubItems(2) = Cells(i, 3)
    Next i
    
    End With
    
    Set ListView1.SelectedItem = Nothing
    Set lstv = Nothing
End Sub
 
Geri
Üst